Created
May 11, 2019 17:30
-
-
Save daniellansun/7d3d55c2645e6040c779db17f25e3f2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Show some new features of Groovy3 | |
// The complete new feature list can be found at: | |
// https://github.com/danielsun1106/groovy-parser | |
@groovy.transform.CompileStatic | |
def helloGroovy3() { | |
File f = new File("D:/hello-groovy${1 + 2}.txt") | |
try (Writer out = new FileWriter(f)) { // try-with-resources | |
out << | |
['hello', 'groovy3', 'Hello', 'Groovy3'].stream() | |
.filter(e -> !Character.isLowerCase(e[0] as char)) // lambda expression | |
.map(String::toUpperCase) // method reference | |
.toArray(String[]::new) // constructor reference | |
.join(', ') | |
} | |
assert 'HELLO, GROOVY3' == f.text | |
} | |
helloGroovy3() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment