KT
kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
fun main(args: Array<String>) {
println(
"*** Lambda expressions in Kotlin ***\n")
// Basics syntax
/*
* To create lambda expression that just
* prints Hello, world! we write:
*/
val printHello = {
println("Hello, world!\n"
+"Let's get started with Kotlin.")
}
// We may invoke this function using
// either syntax:
printHello()
println("\n")
/*
* When we need to create a lambda that
* takes parameters we use syntax:
*/
val sayHello = { user: String ->
println("Hello, $user!")
}
sayHello("Dan&Jel")
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run