AST Transformations

Other topics

@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

Contributors

Topic Id: 4635

Example Ids: 16283

This site is not affiliated with any of the contributors.