You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@ThrawnCA: In both cases, an instance of the (super)class Parser has to be created. So I don't understand why there would be a difference in the number of objects created.
FII_USE_FUNCTION_IDENTITY makes sense for cases like:
i.e. where the existing Function object can be assigned as-is.
To illustrate, the following prints "4":
Parser<String> a = s -> s;
Parser<String> b = Function.<String> identity()::apply;
Function<String, String> c = Function.identity();
Function<String, String> d = Function.<String> identity()::apply;
System.out.println(newHashSet<>(asList(a, b, c, d)).size());
This also means that even in d a separate object is created, due to the ::apply indirection. This indirection is necessary in the Parser case, because Function is not assignable to Parser.
FII_USE_FUNCTION_IDENTITY is shown on the STRING constant in the following example:
Although specifying
would work, I'd argue that this doesn't make sense here.
The text was updated successfully, but these errors were encountered: