fork(7) download
  1. class ExtensionExample {
  2. var name: String? = null
  3.  
  4. fun Any?.toString(): String {
  5. return if (this == null) "Value is null" else "Value is not null"
  6. }
  7.  
  8. fun foo() {
  9. println(name.toString())
  10. }
  11. }
  12.  
  13. fun main(args: Array<String>) {
  14. ExtensionExample().foo()
  15. }
Success #stdin #stdout 0.07s 23988KB
stdin
Standard input is empty
stdout
Value is null