4 ms·
I just see that as a non-argument. No one in their right mind returns null instead of Optional.empty() and I've never seen it done in the wild. Regardless in k
by vips7L 6y ago
I just see that as a non-argument. No one in their right mind returns null instead of Optional.empty() and I've never seen it done in the wild.
Regardless in kotlin you can simply do:
val s: String? = null
return s as String
or
val s: String? = null
!!s.trim()
and lose all safety around nullability. Both hinge on a rogue developer not following best practices.
- The_Colonel 6y agoI've seen both Optional<?> return null (inexperienced dev) and somebody arguing we should defensively check for null Optionals as well (experienced dev). What you're arguing is a false equivalence. In practice null safety isn't a problem when developing in Kotlin while it is a big problem in Java.