Generic lambdas
Miles Sabin
miles at milessabin.com
Tue Feb 7 03:09:50 PST 2012
I just tried this again with the latest snapshot, but still no joy.
What's the current plan for generic lambdas? Are they still in?
Cheers,
Miles
On Wed, Nov 16, 2011 at 5:59 PM, Miles Sabin <miles at milessabin.com> wrote:
> I've just been attempting to play with generic lambdas using the
> binary JDK 8 snapshot posted a few days ago,
>
> miles at lewis:lambda$ /usr/java/lambda-jdk/bin/java -version
> openjdk version "1.8.0-ea"
> OpenJDK Runtime Environment (build 1.8.0-ea-b1314)
> OpenJDK 64-Bit Server VM (build 23.0-b04, mixed mode)
>
> I took this example from the EDR,
>
> public class Lambda {
> public static interface Picker {
> <T> T pick(T first, T second);
> }
>
> public static void main(String[] args) {
> Picker rand = <T> (T first, T second) -> new
> Random().nextBoolean() ? first : second ;
> int i = rand.pick(1, 2);
> String s = rand.pick("a", "b");
> }
> }
>
> But this fails compilation as follows,
>
> miles at lewis:lambda$ /usr/java/lambda-jdk/bin/javac Lambda.java
> Lambda.java:7: error: illegal start of expression
> Picker rand = <T> (T first, T second) -> new
> Random().nextBoolean() ? first : second ;
>
> ^
> 1 error
>
> Is this expected at present?
>
> Cheers,
>
>
> Miles
>
> --
> Miles Sabin
> tel: +44 7813 944 528
> gtalk: miles at milessabin.com
> skype: milessabin
> g+: http://www.milessabin.com
> http://twitter.com/milessabin
> http://www.chuusai.com/
--
Miles Sabin
tel: +44 7813 944 528
gtalk: miles at milessabin.com
skype: milessabin
g+: http://www.milessabin.com
http://twitter.com/milessabin
http://www.chuusai.com/
More information about the lambda-dev
mailing list