ZenScript main repository
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

functions_lambdas.zs 413B

12345678910111213141516171819202122
  1. val outOfScope = 10;
  2. val fun1 = (a as int, b as int) as int => a + b * outOfScope;
  3. val fun2 = (a as int, c as int) as int => 13;
  4. function apply(fn as function(value as int) as int, scale as int) as int {
  5. return fn(scale);
  6. }
  7. println(fun1(30, 20));
  8. println(fun2(30, 20));
  9. function scale(value as int, scale as int) as int {
  10. return apply(v => v * scale, value);
  11. }
  12. println("Value: " + scale(10, 5));