id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Lambda IntroStringLambda3

prev  |  next  |  chance

val upperIt2: (String) -> String = { s: String -> s.uppercase() + s.uppercase() }

// Simplify things with it
val upperIt3: (String) -> String = { it.uppercase() + it.uppercase() + it.uppercase() }

fun upperIt3(s: String): String = s.uppercase() + s.uppercase()

// Higher-order function as a parameter
fun func3(s: String, func: (String) -> String): String = func.invoke(s)

Function Call  Return Value
func3("abc", upperIt2)
func3("table", upperIt3)
func3("house", ::upperIt3)

Experiment with this code on Gitpod.io or as a Kotlin Playground

⬅ Back