java - How do method references in RxJava work? -
can explain me, how come both of lambdas can replaced method references here?
in rxjava, map() takes parameter of type func1<t, r>, comment states "represents function one argument". understand why valueof(object) works here. trim() takes no arguments @ all.
so how work exactly?
observable.just("") .map(s -> string.valueof(s)) //lambdas .map(s -> s.trim()) // .map(string::valueof) //method references .map(string::trim) // .subscribe();
i didn't play rx in java, please note, string::valueof static (aka unbound) function, while string::trim non-static (aka bound) function have indirect this argument. so, in fact, both function takes single argument. in java it's not visible in python example.
Comments
Post a Comment