Unlike Java, Kotlin distinguishes between nullable and non-nullable types. If you are handling possible null
values, you need to decide what to do with them.
The safe (?
) operator allows you to do this without and endless amount of if/else conditions.
https://kotlinlang.org/docs/reference/null-safety.html
- Refactor the code to avoid the
if (null)
check