Skip to content

Instantly share code, notes, and snippets.

@channyeintun
Created May 6, 2021 08:35
Show Gist options
  • Select an option

  • Save channyeintun/3efb648757e1aca16c396d2a304f409e to your computer and use it in GitHub Desktop.

Select an option

Save channyeintun/3efb648757e1aca16c396d2a304f409e to your computer and use it in GitHub Desktop.
fun add(a:Int,b:Int):Int= a+b
fun hof(a:Int,b:Int,func:(Int,Int)->Int)=func(a,b)
fun main() {
val result1:Int=hof(3,4,::add)
println("result1=$result1")
val result:Int=hof(1,2,func={a:Int,b:Int->a+b})
//val result:Int=hof(1,2){a:Int,b:Int->a+b}
println("result=$result")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment