#Why isn't intellij suggesting to replace a lambda expression with method reference?
16 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @crimson timber! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Even thought it's valid syntax to use the method reference, i just don't get why it's not suggesting for line 1 to use a method reference like line 2
Line 1 and 2 do the exact same thing, only 2 uses the method reference and 1 is just a normal lambda
Is it because the first line takes 2 parameters (i.e. is a BiFunction) but hasPermission only takes one? So it can't a method reference would be ambiguous (which parameter should I use?)
Are there 2 hasPermissions?
There's only 1 hasPermission function, and it takes 1 parameter which takes the same type as source
the where function is defined as <T> Linq<E> where(T param, BiFunction<E, T> func), the extra T parameter is only there as a tiny micro optimisation so that a lambda class isn't allocated in order to capture source
oh wait i think i figured it out...
there was 2 but one was static
and took a string as a 2nd parameter
so maybe it was ambiguous enough
Yeah that would be it