53 Lambdas
A lambda creates a function value at the use site. Its parameter and result types follow the expected function type; its final expression supplies the result.
norm
Integer apply(Integer transform(Integer number), Integer input) {
return transform(input)
}
main() {
Function<Integer(Integer)> twice = (number) {
number * 2
}
printLine(twice(5))
printLine(apply(transform: (number) { number + 3 }, input: 5))
}Expected output:
text
10
8Try it: Change number + 3 to number * 3 and predict the second line.
Precise rules: Reference.