Building upon that, I'd prefer `when (stuff)` to a...
# language-proposals
l
Building upon that, I'd prefer
when (stuff)
to allow just calling methods, adding the receiver to the branch conditions, or have
stuff.when
do that as a new special syntax. (Thinking about how it would translate to actual uses cases, I think I prefer that latter approach)
b
I don’t care either way. I think I would prefer
when(stuff)
but that might just be me.
r
There's an issue in the tracker you can vote for: https://youtrack.jetbrains.com/issue/KT-28359
l
Thanks @Ruckus, I added a comment for my alternative syntax proposal.
👍 1
h
your proposal also might make way for
Copy code
when (a) {
    < b -> foo()
    b   -> bar()
    > b -> baz()
}
instead of
Copy code
when (a.compareTo(b)) {
    -1 -> foo()
    0 -> bar()
    else -> baz()
}
the former reads a lot more akin to the equivalent mathematical syntax