New JEP: Switch Expressions for the Java Language
jan.lahoda at oracle.com
Fri Dec 8 16:35:12 UTC 2017
I've just pushed a crude prototype of switch expression and case null to
the amber/amber repository, branch switch. There are probably many bugs
in the prototype.
-switch expression (using syntax from the JEP, including the block
expression); target typing still needs some work; exhaustiveness for
enums should work (but the error thrown for incompatible changes is not
ideal and needs some work).
-case null: (does not yet use the indy desugaring scheme Brian sent though)
-comma separated case alternatives in the statement switch, not yet
supported in the expression switch.
throw expressions not supported by the prototype.
Please let me know if there are any comments.
On 7.12.2017 23:30, Brian Goetz wrote:
> In the context of Pattern Matching (JEP 305) we've explored a number of
> improvements to `switch`, including switch expressions, expanding the
> range of types that can be arguments to switch, better null handling,
> and others. Many of these can be developed independently of pattern
> matching; we've separated out a package of these features into their own
> JEP, as they stand well on their own:
More information about the amber-dev