I want to understand the reasons behind this piece...
# language-proposals
v
I want to understand the reasons behind this piece of design: Inside
when
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