Mismatch between the order of the type variable and the order of the SAM method formal parameters

Rémi Forax forax at univ-mlv.fr
Thu Sep 15 00:30:05 PDT 2011


Hi all,

Here is the declaration of a Reducer:

   interface Reducer<T, U> {
       U reduce(U base, T t);
   }

and how to use it:

   Reducer<String, Integer> reducer = (Integer i, String s) -> i + 
s.length();

As you see the order of the type argument <String, Integer> is not
the same as the order of the type of the formal parameter of the lambda 
(Integer i, String s).
I think it will be simpler if the signature of reduce() was changed to 
swap the two
formal parameters.

Rémi



More information about the lambda-dev mailing list