If you are using Java8 and want to try the native lambda, please add addition
JVM options( `-Dgroovy.target.bytecode=1.7 -Dgroovy.antlr4=true` OR
-Dgroovy.target.bytecode=1.8 -Dgroovy.antlr4=true)
For example:
1) Run script via command line
```
groovy -Dgroovy.target.bytecode=1.8 -Dgroovy.antlr4=true
TryNativeLambda.groovy
```
2) Run script in groovy console
a) set the environment variable `JAVA_OPTS` as
`-Dgroovy.target.bytecode=1.8 -Dgroovy.antlr4=true`
b) run `groovyConsole`
Here is a sample script for you to try:
```
import groovy.transform.CompileStatic
import java.util.stream.Collectors
import java.util.stream.Stream
@CompileStatic
public class Test1 {
public static void main(String[] args) {
p();
}
public static void p() {
println([1, 2, 3].stream().map(e -> e.plus 1).toList())
}
}
```
In next releases of 2.6.0, `-Dgroovy.target.bytecode=1.7` will be set
by default.
Cheers,
Daniel.Sun
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html