No 'fold left' without a combiner ?

Remi Forax forax at
Sun Sep 8 09:18:26 PDT 2013

Did I say that I will send you an email to the EG lists each time I will 
be annoyed by visibility of lambda parameter rule ?

ArrayList<Advice> advices = ...
AnnotatedElement annotatedElement = ...
MethodHandle mh =, (mh, advice) -> 
advice.chain(annotatedElement, mh), null);

In fact, there is another issue, (the real reason of this email), this 
code throws a NPE at runtime because I use null as combiner.
It seems there is no way to express a left fold on values (different 
from T) when the values can not be combined.

I've fixed the issue by writing,
   MethodHandle target =,
       (mh, advice) -> advice.chain(annotatedElement, mh),
       (_1, _2) -> { throw new AssertionError(); } );
but it's clearly ugly.


More information about the lambda-spec-experts mailing list