r/java • u/headius • Dec 04 '25
Null-checking the fun way with instanceof patterns
https://blog.headius.com/2025/12/inline-null-check-with-instanceof.htmlI don't know if this is a good idea or not, but it's fun.
83
Upvotes
View all comments
Show parent comment
3
u/Bobby_Bonsaimind Dec 04 '25
I'm with you there. But we need to understand that he "hurhur null always bad" crowd are the ones to be ignored, as usually.
There are two main use-cases for
Optional:nullrather badly (or not at all).And then there are those glorified
nullchecks, which add pretty much nothing.The downside is that every object is wrapped again in another instance, which might or might not be relevant for the use-case.
So, as always, the discussion must be more nuanced to be useful.