February 2019
Intermediate to advanced
442 pages
11h 46m
English
Every programming language has a provision for defining the literals, such as string, integer, double, and so on. They can be defined in a specific manner such as string literal as Hello, double literal as 34.23, and so on. Kotlin allows us to define a function as a literal by enclosing the code in braces as follows:
//This is functional literal{ println(" This is function literal ")}
This function can be declared in a normal way as follows:
fun printMsg(message:String){ println(message)}
It is essentially the same thing as a function literal. But the functional literal looks pretty compact yet expressive. A function literal can be assigned to a variable and called at a later point of the code as follows: ...