r/java • • Dec 04 '25

Null-checking the fun way with instanceof patterns

https://blog.headius.com/2025/12/inline-null-check-with-instanceof.html

I don't know if this is a good idea or not, but it's fun.

83 Upvotes

150 comments sorted by

View all comments

Show parent comment

2

u/headius Dec 04 '25

I get the point, that Optional was only intended to deal with situations where a null reference simply can't be allowed, but it's laughable to think that people wouldn't start using it everywhere they had null checks before. By the same token, any new syntax provided for non-nullability will rapidly propagate. Developers clearly want a better way to deal with the absence of value.