groovy

AST Transformations

@CompileStatic

Enables a code to be statically compiled. Its bytecode will be closer to Java’s, thus having better performance, though some dynamic features won’t be available.

@groovy.transform.CompileStatic
class ListMath {
    def countSize(List<String> strings) {
        strings.collect { it.size() }.sum()
    }
}


assert new ListMath().countSize(["a", "bb", "ccc"]) == 6

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow