- 
                Notifications
    
You must be signed in to change notification settings  - Fork 24
 
Higher Order Functions: Examples
        Devrath edited this page Feb 11, 2024 
        ·
        1 revision
      
    Code
val action :() -> Unit = { println("Hello World!!")  }
fun main(args: Array<String>) {
    // Calling the action
    action()
    action.invoke()
}Output
Hello World!!
Hello World!!Code
val action :() -> Unit = { println("Hello World!!")  }
fun main(args: Array<String>) {
    // Calling the action
    consumeAction(action)
}
fun consumeAction( action :()-> Unit ){
    action()
    action.invoke()
}Output
Hello World!!
Hello World!!