Chills
03/22/2020, 11:17 AMtseisel
03/22/2020, 1:12 PMval result: Int = { param: String ->
// Do something that returns an Int. All local variables in this scope are private, and you can reference variables from the outside.
}("Hello World!")
Please note that this is really a weird syntax for Kotlin.
If all you need is to avoid polluting the global scope, use the run
function:
val result = run {
val foo = "I'm local"
foo.toUppercase()
}