great stuff
On 25.10.2016 18:25, Daniel.Sun wrote:
Hi all,
The brand new parser can support method reference and constructor
reference now. The implementation of backend is based on the discussion of
GROOVY-7772 <https://issues.apache.org/jira/browse/GROOVY-7772> .
Here are some example code of method reference for Groovy:
import java.util.stream.Collectors
assert ['1', '2', '3'] == [1, 2,
3].stream().map(Integer::toString).collect(Collectors.toList())
assert ['A', 'B', 'C'] == ['a', 'b',
'c'].stream().map(String::toUpperCase).collect(Collectors.toList())
assert [new String[1], new String[2], new String[3]] == [1, 2,
3].stream().map(String[]::new).collect(Collectors.toList())
( Complete example code can be found at:
https://github.com/danielsun1106/groovy-parser/blob/master/src/test/resources/core/MethodReference_01x.groovy
<https://github.com/danielsun1106/groovy-parser/blob/master/src/test/resources/core/MethodReference_01x.groovy>
)
At last, I want to thank *Jochen Theodorou* who explained the whole
discussion of GROOVY-7772 in detail for me.
*PS:* if you want to give it a try, follow the step:
$ git clone https://github.com/danielsun1106/groovy-parser.git
$ cd groovy-parser
$ ./gradlew groovyConsole
Cheers,
Daniel.Sun
--
View this message in context:
http://groovy.329449.n5.nabble.com/Method-reference-for-Groovy-3-tp5736296.html
Sent from the Groovy Dev mailing list archive at Nabble.com.