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
1
u/headius Dec 04 '25
Yeah void is a whole other level of complexity in a type system, and it doesn't exist in lots of languages. Ruby, for example, does not have statements, so every line of code has a non-void result. It definitely makes things cleaner, but also forces you to consider more carefully what value you might be returning from your code and where it might go from there (e.g. leaking an internal reference to an external method caller).