3 ms·
Null safety is the one big win for Kotlin. https://kotlinlang.org/docs/reference/null-safety.html https://kotlinlang.org/docs/reference/null-safety.html
by watt 7y ago
Null safety is the one big win for Kotlin. https://kotlinlang.org/docs/reference/null-safety.html https://kotlinlang.org/docs/reference/null-safety.html
- vips7L 7y agoI agree, but like I said it's not enough for me to switch. I use Optional<T> whenever I need to return null. The only outlier there is the JDK which most devs should know when it's returning null to you.
- dajohnson89 7y agoisn’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 }