groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remi Forax <fo...@univ-mlv.fr>
Subject Re: Lambda expression for Groovy 3
Date Wed, 19 Oct 2016 10:29:58 GMT
Daniel,
you have also to test that Type::method work not only with static methods but also with instance
method.

The awful case being when you have a static method that takes an instance in parameter that
'overload' an instance method, like Integer.toString() and Integer.toString(int).

Rémi

----- Mail original -----
> De: "daniel_sun" <realbluesun@hotmail.com>
> À: dev@groovy.incubator.apache.org
> Envoyé: Mercredi 19 Octobre 2016 12:23:09
> Objet: Re: Lambda expression for Groovy 3

> Hi Jochen,
> 
>      I plan to map Java's *::* to Groovy's *.&*, the following code is ok
> now. What do you think about it?
> 
> [1, 2, 3].stream().forEach(System.out.&println)          // object method,
> [1, 2, 3].stream().forEach(System.out::println)
> [1, 2, 3].stream().forEach(Objects.&requireNonNull) // class method,  [1, 2,
> 3].stream().forEach(Objects::requireNonNull)
> 
> Cheers,
> Daniel.Sun
> 
> 
> 
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp5736169p5736195.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.

Mime
View raw message