https://kotlinlang.org logo
#android
Title
# android
k

Kulwinder Singh

10/10/2017, 6:21 AM
I want to know why I have to pass dataManager(instance of DataManager), I only want that when I call getData() ,then at call time I have to pass function of DataManager that takes only parameter WebDataListener<T>
e

edwardwongtl

10/10/2017, 8:05 AM
Because the type of
func
is
DataManager.(Listener) -> Unit
, you have to specify which
DataManager
is used to receive the
.(Listener) -> Unit
function call
k

Kulwinder Singh

10/10/2017, 8:07 AM
ok I got it
but one last thing I want to know is that,i only want to perform function call of func() in getData() but I also have to specify it parameters when I am calling getData()
e

edwardwongtl

10/10/2017, 8:15 AM
I don't quite get what you mean, could you explain a bit?
getData(listener) {}
is what you need to call
getData()
, you don't have to pass a
DataManager
into the lambda
k

Kulwinder Singh

10/10/2017, 8:21 AM
i only want to call HighOreder (func) inside getData() function, but when i calling getData() then i am asked to call func like getData(otherParams){ BaseDataDelegation(this,listener)// i don't want to call it here}
e

edwardwongtl

10/10/2017, 8:25 AM
The point of higher order function is that the caller don't need to know the function impl, the impl is provided by the caller
k

Kulwinder Singh

10/10/2017, 8:27 AM
but can i use method refrence here like DataManger::functionName , actully i have used this and its working , i want your advice
e

edwardwongtl

10/10/2017, 9:15 AM
That's the correct way I think
k

Kulwinder Singh

10/10/2017, 9:18 AM
yea its working correctly but i don't have any Refrence of it so therefore i'm doubting this and not sure about it