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 ?
returninside the body behaves differently. Like, in the first case, it'll be a return frommyFunction, while in the second 1) in your current code you can't use return 2) As an argument to functions accepting lambdas it'll be a return from outer function. Also I suspect that first case disables inlining when passed as an argument.