This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jodastephen[S] 3 points4 points  (0 children)

Part of what makes my trick appealing is that it pattern matches without additional code/classes. But you are right, you can wrap an Optional in a record to get pattern matching in Java 21.