Last active
March 29, 2018 17:52
-
-
Save LittleHelicase/3d104d669dac236b90120408734cf32e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Int?.toString() { | |
return "42" | |
} | |
fun Any?.toString() { | |
if (this == null) return "null" | |
return toString() | |
} | |
fun main(args : Array<String>) { | |
val x = null | |
println(x.toString()) // prints "42" (even though it is not defined as Int?) | |
val y : String? = null | |
println(y.toString()) // prints "null" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment