This is happening to me multiple times.. I find `w...
# language-proposals
e
This is happening to me multiple times.. I find
when
and the possibility to declare some
val
quite limiting:
Copy code
val platform = when(val os = DefaultNativePlatform.getCurrentOperatingSystem()) {
    os.isWindows -> 0
    
}
if I declare something like that,
when
expect exclusively matches against
os
Type I'd like something more broad
m
I often have the same problem and it’s a little annoying that I have to introduce another scope. Your example would be ambiguous though. Will it evaluate the expression using
==
or treat it as a boolean? That’s probably a general problem with
when
. Some use
==
(and support partial
is …
) while some expect a boolean value.
e
==
if type matches, boolean otherwise
like one would normally expect
m
That would be quite hidden/difficult to see and can lead to subtle errors. Take
Any
as an example. Can be
==
checked against everything.
e
corner situations may simply highlighted by the IDE