voddan
01/16/2016, 11:29 AMwhen
expression brackets {}
has a special meaning: when(a) { 0 -> {"ok"} }
means return "ok"
.
This is inconsistent with the rest of the syntax when(a) { 1 -> "no" }
, because by logic that would mean return {"ok"}
, which is a lambda
The same result can be achieved with a standard helper method when(a) { 1 -> run{"ok"} }
Q: what justifies the irregularity in the syntax
i think it goes mostly to the team, so: @yole , @udalov , @orangy