Round 1 feedback
brian.goetz at oracle.com
Wed Feb 13 20:05:58 PST 2013
> Going back to this one, this doesn't work as computeIfAbsent requires
> a Function whose first argument is the key :-(
Ah, right; you want
k -> new ArrayList<>()
> Is there any chance such conversions with method references are
> possible, i.e., when their arity is less than the functional interface
> method arity?
This seems harmless, but would hurt you worse in the end. The more
automatic adaptation we try and do here, the harder it is to do overload
For example, if you have a function:
you can call it with
and the compiler will eliminate all the other constructor candidates
because it knows the target type is () -> List<T>. (Remember, it
doens't know which TreeSet constructor you are asking for, and there are
more than one, so it has to do overload selection.) If we allowed fuzzy
matching, then its ability to prune the "obviously wrong" choices
necessarily goes down.
So rather than try to make method ref matching magic, we just use a
lambda, which allows you more control.
More information about the lambda-dev