Kotlin fun() vs lambda is there difference?
问题 This question is about fun() vs a lambda block definitions and scopes. i have tried define the expressions in two ways. Here is what i have tried: val myFunction = fun(){ println("i am in a function") } //but i also tried doing this: val myFunction = { println("i am in a lambda") } my problem is i do not know if they are equivalent and same thing ? 回答1: The differences are best described in https://kotlinlang.org/docs/reference/lambdas.html#anonymous-functions: Anonymous functions allow you