I am referring to the Null-Safety in Kotlin:
A colleague of mine writes always like:
bob ?: return
bob.department ?: return
bob.department.head ?: return
bob.department.head.name()
Readability is his argument. This is for me not very Kotlin like and more overelaborated. Of course I prefer:
bob?.department?.head?.name()
Some arguments/docs/links not using upper way would be very helpful.
I would like to know if there are any disadvantages using upper way? Also, I can imagine that some compiler optimization won't work very well, doing the upper way?
EDIT: According to SVN the history tells:
if (bob != null) {
if (bob.department != null) {
if (bob.department.head != null) bob.department.head.name()
}
}