Quick actions

cmd+k|ctrl+k

Navigation

Languages

Function Type With Nullable

Snippet info

Language

Kotlin

Visibility

public

Author

habib17

Created

2019-11-02T00:40:02Z

Updated

2019-11-02T00:40:02Z

fun main(args : Array<String>){
    
    val sumResult = sum?.invoke(10, 10)
    println(sumResult)
    //tanpa invoke
    val multiplyResult = multiply(20, 20)
    println(multiplyResult)
}
//null able
typealias Arithmetic = (Int, Int) -> Int ?

val sum: Arithmetic = { valueA, valueB -> valueA + valueB }
val multiply: Arithmetic = { valueA, valueB -> valueA * valueB }
INFO