`it` cannot be added, because it can change a mean...
# announcements
o
it
cannot be added, because it can change a meaning of some
it
already used
1
r
Out of curiosity, if you could go back and change the design from the get-go, would you use the 1.3 design or an have
when
use a more lambda-ish syntax?
Copy code
when (getData()) { data ->
   data is Thing -> ...
   ...
}
Which could then use
it
o
I didn’t try to design it from ground up, so I don’t have an answer. But personally, I’d try to make it possible so that
when
is actually a function 🙂
e
Support for when-like functions is still a possibility, imo. Can be retrofitted in a backwards-compatible way. I find use-cases for that from time time.
4
r
@orangy Fair enough. That could be interesting.
@elizarov Do you mean like the coroutine select expressions?
e
things like that. but not only that.
It is about alegebraic types with internally encapsulated structure.
So, we support it for product types. If you have an encapsulated color you can destruct it into (r, b, g) via
componentX
operators
But we don’t have that for sum types
r
Ah, okay. Is that something that could be worked around with the new
KClasses.sealdSubclasses
?
l
@elizarov Would a custom when like be just a function, or a class, or an interface? Do you think it may be considered in a future Kotlin version? I also had several use cases where I wish I could define a when like construct
o
No design, no plans, nothing yet
But while we are here, I often want to implement interfaces anonymously in short form like this:
Copy code
widget.addListener { 
     move -> …
     click -> …
     cancel ->  …
}
where
move
,
click
and
cancel
are methods of the interface that I need to pass to
addListener
. Multi-lambda if you wish.
6
r
@orangy I've wanted something very similar every time I have to do any Swing development.