Personally, I would try to avoid `null` though.
# getting-started
e
Personally, I would try to avoid
null
though.
d
enighma: Why do you wish to avoid
null
?
e
I guess the greater answer to that is I like to avoid side effects. Sometimes you can’t and in Kotlin you have more control over when something is null. But if there’s a way to not use it will create cleaner implementations, generally.
d
Unless you are interfacing this code with Java code then
null
is entirely safe and side effect free though right? The fact that it is built into the type system means you must consider the optionality of the variable at hand.
e
null is a side effect in itself. An object can be null for many reasons and the reasons might be important. I kotlin it’s at least explicit since we have nullable types, in Java we have no safety net whatsoever. E.g. a consumer of a Java API can’t know if null is a valid parameter or return value. Nullable annotations levitate that somewhat, but it’s not not up to par with “modern" languages.