Quick actions

cmd+k|ctrl+k

Navigation

Languages

Nullable Receiver

Snippet info

Language

Kotlin

Visibility

public

Author

habib17

Created

2019-11-01T14:42:10Z

Updated

2019-11-01T14:43:46Z

fun main(args : Array<String>){
    val value: Int? = null
    println(value.slice)
}

//dengan if else
    val Int?.slice : Int
   // get() = if (this == null) 0 else this.div(2)
   //dengan elvis operator
   get() = this?.div(2) ?: 0
INFO