Pattern matching on multiple objects
David Alayachew
davidalayachew at gmail.com
Sun Apr 23 17:18:53 UTC 2023
Hello,
For whatever reason, I remember seeing this as another potential future
direction for Java.
$ build/windows-x86_64-server-release/images/jdk/bin/jshell --enable-preview
| Welcome to JShell -- Version 21-internal
| For an introduction type: /help intro
jshell> sealed interface ABC {
...> enum A implements ABC {Z}
...> record B(A a) implements ABC {}
...> record C(A a, B b) implements ABC {}
...> }
| created interface ABC
jshell> final ToIntFunction<ABC> d =
...> abc ->
...> switch (abc) {
...> case C(A.Z, B(A.Z)) -> 1;
...> default -> 0;
...> };
I think it was called constant patterns?
Thank you for your time!
David Alayachew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230423/fdad27cc/attachment.htm>
More information about the amber-dev
mailing list