ZenScript main repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

match.zs 651B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. val test as int = 10;
  2. val tt1 = "tt";
  3. val tt2 = "tt3";
  4. val tt4 = "tt5";
  5. println(match 10 {
  6. 1 => "one",
  7. 10 => "yo",
  8. //tt1 === "tt1" for some compiler issue it takes the variable as string input?
  9. 100 => match tt1 {
  10. "10" => "t",
  11. "tt1" => tt1,
  12. "tt2" => tt1 + tt4,
  13. default => tt4
  14. },
  15. default => tt2
  16. });
  17. println(tt1);
  18. //println(match test {
  19. // case 1 : "tt",
  20. // default : "kk"
  21. //});
  22. function myFunc (par1 as int) as void {
  23. val v0 = par1 - 1;
  24. println(match par1 {
  25. 10 => v0,
  26. default => match(v0) {
  27. 10 => 99,
  28. default => v0
  29. }
  30. });
  31. }
  32. myFunc(10);
  33. myFunc(11);
  34. myFunc(12);
  35. val t = (a as int) as int => a;
  36. println(t(10));