On Sat, Aug 28, 2010 at 5:36 AM, Kevin Wright <[email protected]>wrote:

>   final List<Integer> myList = ImmutableList.of(1,2,3);
>   final Function<Integer, Integer> f = new Function<Integer, Integer> {
>     public Integer apply(Integer from) {
>       return from * 2;
>     }
>   }
>   final List<Integer> result = Lists.transform(myList, f);
>
>
> So yes, SAM types are nasty when compared to the alternative...
>

Actually, this is not a SAM example, it's just the way we do closures in
Java today.

Here's what  we'll be able to do with the JDK 7:

list.map(#(int n) n * 2)

or

Lists.map(l, #(int n) n * 2)

Regardless of the final syntax, I think the addition of closures in the JDK
is a great compromise: adding a feature that a lot of developers feel
comfortable with without introducing all the extra baggage that Scala comes
with.

-- 
Cédric

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to