fun myFunction(x: Number?) { if (x == null) return; print(x + 1); }
You can also do:
x?.let {notNullX -> print(notNullX + 1)}
print((x ?: 4) + 1)
It really is an awesome language. Especially the delegated properties are wonderful. I use them to fill javascript-state for redux/react-native.
You can also do:
or https://kotlinlang.org/docs/reference/null-safety.htmlIt really is an awesome language. Especially the delegated properties are wonderful. I use them to fill javascript-state for redux/react-native.