November 2018
Intermediate to advanced
388 pages
9h 5m
English
Functional programming can be advantageous when we are performing lots of different operations on data that has a known, fixed amount of variation. It provides a very elegant way to write code with immutability. It also allows you to write pure functions.
A lambda expression is an anonymous function that represents the implementation of single abstract method (SAM) of an interface. Lambda expressions deal with expressions and promote immutability, which turn functions into higher-order functions.
Let's write a lambda expression. Consider the following code for 12_LambdaExpressions_HelloWorld.kts:
val greetingLambda = { println("Hello from Lambda")}greetingLambda()
The output is as follows:
We can invoke lambda ...
Read now
Unlock full access