f(x) syntax sugar in Lambda

Spot Al stellarspot at yandex.ru
Wed Feb 8 23:41:42 PST 2012


Hi,

For example if there is an interface 
-----------------------------------------------
 interface Exponent{
     double calculate(double x);
 } 
-----------------------------------------------

and I have a lambda expression:
-----------------------------------------------
Exponent exp = (x) -> 1 + x + x * x / 2;
-----------------------------------------------

would it be possible to get a value like:
  double e = exp(1);
instead of 
  double e = exp.calculate(1); ?

Where exp(1) just a syntax sugar for the exp.calculate(1).

So if variable a has a lambda type (interface with one method) than a(val1,.., valN) means a.methodName(val1,.., valN)?

Thanks,
Alexander.






More information about the lambda-dev mailing list