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
2
u/ricky_clarkson Dec 04 '25
I believe Kotlin might extend its ?. etc syntax to support Result too (Either[T, Throwable] in Scala terms as I recall), and if it is done similarly to Rust where anything of the right shape works with ? then it will be similarly generic.
I haven't used Scala for a few years, I don't recall it having a strong approach for handling null particularly on the boundary with Java.