Skip to content

Returning Function

Devrath edited this page Feb 10, 2024 · 2 revisions

Example:1

Output

Start of Main program
PERFORM FUNCTIONALITY
End of Functionality
End of Main program

Code

fun main(args: Array<String>) {
   println("Start of Main program")
   displayResult {
       println("End of Functionality")
   }
   println("End of Main program")
}

fun displayResult(endFunction:()->Unit){
    println("PERFORM FUNCTIONALITY")
    endFunction()
}
Clone this wiki locally