Declaring lambdas
Declaring a simple lambda
The simple lambda consists of only a single statement. It will automatically return the result of said statement without the need of the put
keyword.
Example
Declaring a complex lambda
A complex lambda contains multiple LOC and does require the use of the put
keyword to return things.
Example
Lambda return types
Lambdas can state return and input types like so: lambda::(input types)->return type
.
Declaring a lambda without parameters
If no parameter is needed, an _
is used as the parameter name, instead.
Example
Assigning a function to a lambda variable
One can assign a function to a lambda. If the function has function guards, they are being rewritten into a match
block internally. This can be useful when passing a function to a method.
Example
Last updated