Jukka Siivonen
11/13/2018, 7:59 AMedwardwongtl
11/13/2018, 8:13 AMreturn
in map
actually returns to a outer scope?Andreas Sinz
11/13/2018, 8:30 AMJukka Siivonen
11/13/2018, 9:17 AMelizarov
11/13/2018, 10:06 AMreturn
is consistent in that it returns from the enclosing fun
by default. From lambdas you don’t usually return — you program them (usually) in functional style where their value is the last expression.Jukka Siivonen
11/13/2018, 11:23 AMlist.map { it ->
return if (condition) {
Foo()
} else Bar()
}
list.map { it ->
if (condition) {
Foo()
}
Bar()
}
list.map { it ->
if (condition) {
Foo()
} else {
Bar()
}
}
elizarov
11/13/2018, 1:49 PMJukka Siivonen
11/13/2018, 3:38 PM