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

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -