Same outer context in function's inner scope this functional method parameter can give you integer at the time of invocation.Ĭheck out the snippet below: fun someMethodWithCallback(callback: (Int) -> Unit) it DOES NOT change the context of function's scope, so it remains the same as the context where the function was called, e.g.: //Outer context in outer scope Whatever written above simply means: (Int) -> Unit. Parameter by callback means you want to give your callback a parameter that caller can use on the time of invocation, also considered as it.So, there are two possibilities how you want your callback to be: Let's say you've written a function or using a function which provides you callback as lambda method receiver. Difference between it & this keywords can be explained by taking example of lambda method receivers (a.k.a higher order functions).
0 Comments
Leave a Reply. |