4 ms·
isn’t optional just replacing the null check with if(optionalRef.isPresent)?? i kinda get how this is safer, but clients can just call optionalRef.get() withou
by dajohnson89 7y ago
isn’t optional just replacing the null check with if(optionalRef.isPresent)??
i kinda get how this is safer, but clients can just call optionalRef.get() without checking, and boom there goes the safety. compiler warnings be damned.
- vips7L 7y agoOptional is just signaling to the user that they should check. You could also do this in Kotlin and boom there goes the safety: fn nonNull(): String { val s: String? = null return !!s }