DEV Community

Discussion on: Java 8 Optional: A way to avoid NullPointerException

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Yes, optional is a great pattern. Have you tried Kotlin, Swift, or TypeScript which have the choice of non-nullable references? It’s a much more effective way of eliminating null references. That being said, I still use Optional or Either pattern in TypeScript when I want to return one of two types. I’m glad to find another fan of this defensive programming technique. :)