Pattern Matching for switch (Second Preview)

Brian Goetz brian.goetz at oracle.com
Sat Sep 25 18:10:24 UTC 2021


> It's not exactly the same semantics because "Object e" allows null while "default" don't.

The semantics more more different than that; because default has special 
prvileges with respect to ordering.  Bottom line: don't use default in 
pattern switch, use real patterns.

>
>> But I like the default syntax since it can be put to the beginning of the switch
>> expression, and the type of `e` may not always be Object.
> You will be able to use "var" instead of "Object" soon.

Will you ?  News to me.




More information about the amber-dev mailing list