Pattern match Optional in Java 21

from blog Stephen Colebourne's blog, | ↗ original
I'm going to describe a trick to get pattern patching on Optional in Java 21, but one you'll probably never actually use. Using Optional As of Java 21, Pattern matching in Java allows us to check a value against a type like an instanceof with a new variable being declared of the correct type. Pattern matching can handle simple types and the...