Alternative syntax for closures

Rémi Forax forax at univ-mlv.fr
Tue Jul 15 13:16:33 PDT 2008


Neal Gafter a écrit :
> Can you please show me how you intend one would write the equivalent 
> of the following BGGA method?
>
> *<throws E> void myIf(
>       boolean cond,
>       {=>void throws E} truePart,
>       {=>void throws E} falsePart) throws E {
>   (cond ? truePart : falsePart).invoke();
> }
> *
>
> Regards,
> Neal
Voila :
void myIf(boolean cond) truePart() falsePart() {
  if (cond)
    truePart().invoke();
  else
    falsePart().invoke();
}

Rémi



More information about the closures-dev mailing list