You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One issue is that you should rarely have a nullable collection, it's better to use an empty collection, and not have two ways to represent "no elements".
Another is that they syntax could be better used for something else.
If we get Null-aware elements (#323), then you should be able to write:
for (final i in [?myInts]) { ... }
and with a little luck and prodding, the compiler should be able to optimize that into:
if (myInts casefinal myInts?) for (final i in myInts) { ... }
while largely I agree, one situation I have run into this is optional function parameters.
Also, do you mind explaining or linking to whatever pattern-matching foo is happening here: if (myInts case final myInts?) ..., I don't think I've seen that syntax before
Currently, for collection-for's on nullable collections, we need a null check:
It would be nice if we could have a null-aware version of this syntax, something along the lines of
or
which would skip iteration if the iterable were
null
.Sorry if this already exists and I'm just (null-)unaware of it :)
The text was updated successfully, but these errors were encountered: