• my
setContent function sets the content on the screen and calls the lambda function
myFunc1 to do so
• my
Surface function draws borders on the screen and draws its content inside and calls the lambda function
myFunc2 to do this
• my
Text function just displays the text on the screen
We could call it like this:
setContent({ -> some kind of code })
But here is the right way:
setContent{ some kind of code } More what is
Kotlin Lamda Function ...
Kotlin
File Main.kt
fun main() {
setContent {
Surface(
color = "green"
)
{
Text("Hello!")
Text("I want coffee :)")
Text("Thank you")
}
}
}
fun setContent(myFunc1:() -> Unit)
{
myFunc1();
}
fun Surface(color:String, myFunc2:() -> Unit)
{
println("┌---------------------------------")
println("|")
println("|")
myFunc2();
println("|")
println("|")
println("└---------------------------------")
}
fun Text(description:String)
{
println("| $description ");
}