5 ms·
It’s only a preview feature in 12, so you need to give a command line switch to java for it to be enabled. It’s also the first part of a much larger feature ad
by aardvark179 8y ago
It’s only a preview feature in 12, so you need to give a command line switch to java for it to be enabled.
It’s also the first part of a much larger feature adding pattern matching to the Java language. Getting all the ducks in a row for this sort of thing is tricky because it touches so many other ares, but switch expressions can be delivered on their own quite nicely.
Adding patterns means looking at variable scopes (where is a variable bound in a pattern in scope?), record classes (because destructuring patterns should not be implemented by hand everywhere), and even constants and raw string literals (because being able to switch on regexps would be nice, and you need a good way to write that).
- mabbo 8y agoThat sounds lovely. Fully functional pattern matching in Java would be a godsend.