ZenScript main repository
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions_lambdas.zs 434B

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));