Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming / Lambdas and closures / Lambdas
Quiz — Lambdas
What does the following program print?
my &f = -> $x { $x + $x };
say f(9);| 0 | 9 |
| 1 | 18 |
| 0 | 81 |
| 0 | 99 |
The pointy block is a lambda that adds its argument to itself. Called
with 9, it returns 9 + 9, which is
18.