Given the code
fun main(args: Array<String>) {
val someText: String? = null
println(someText.toString())
}
When run, output is
null
Two questions appear:
- is that possible to implement custom null-safe method with fallback to some default code (like, I think, toString does)
- why no exception is thrown?