implicit `this` argument for when statements: ```f...
# language-proposals
h
implicit
this
argument for when statements:
Copy code
fun Any?.isFalsy = when {
    null -> true,
    etc
}
โž– 9
k
You can't overload
when
without an argument either, that already exists.
d
when (this)
reads so much cleaner anyway
๐Ÿ‘ 5
๐Ÿ’ฏ 2
l
the example (
isFalsy
) is not ideal, and would not compile anyway because
fun
has parentheses. That doesn't make your "proposal" shine.
k
@louiscad Just because someone made a typo is no reason to shoot down an idea. I don't like this idea because it decreases clarity, though, which is proven to introduce bugs. That's entirely separate. I can assume that the parentheses were accidentally omitted and that valid code is assumed instead of
etc
๐Ÿ‘ 3
l
@Ky Leggiero I didn't "shoot down" the idea, I just wrote what many people are likely to think while reading the example, and I built upon the idea back in the channel. In other words, I tried to communicate what I think could be better for next time, and I bounced off the idea, taking inspiration.
๐Ÿ‘ 1
k
That might be a better way to put it next time, rather than
would not compile anyway because
fun
has parentheses. That doesn't make your "proposal" shine.
l
I think that my statement is still true. It's better to ensure people focus on the added value than the mistakes or unrelated stuff.
๐Ÿ‘ 1
k
Indeed it is true. I'm just trying to help people feel more welcome, and to make the environment here feel less hostile.
๐Ÿ‘ 2
l
And I totally agree with you. It's sometimes hard to make people feel welcome while telling the truth needed for improvement. What I can say is that I welcome people with good intentions, and that mistakes are only a way to learn and get better.
๐Ÿ˜ 1