jinbeom hong
04/05/2018, 8:32 PMval sum: Int.(Int) -> Int = { other -> plus(other) }
val sum = fun Int.(other: Int): Int = plus(other)
According to document(https://kotlinlang.org/docs/reference/lambdas.html#function-literals-with-receiver), when i use anonymous function, The anonymous function syntax allows you to specify the receiver type of a function literal directly. This can be useful if you need to declare a variable of a function type with receiver, and to use it later.
. What does it mean? Why do i can’t use a variable of function type(not anonymous function but val intPlus: Int.(Int) -> Int = Int::plus
) later?diesieben07
04/05/2018, 8:48 PMthis
) of type Int
, which you can access. This is because the type of the lambda is specified as a "function with receiver".jinbeom hong
04/05/2018, 10:47 PMto use it later
)? Using lambda, we can’t do that?karelpeeters
04/06/2018, 6:22 AMdiesieben07
04/06/2018, 7:35 AMdiesieben07
04/06/2018, 7:36 AMjinbeom hong
04/06/2018, 11:02 AM