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