Groovy web console

subscribe to the feed Subscribe
to this
site

Compile Static

Published 2 months ago by Anonymous
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.transform.*

// Script works without this. When you enable the line it causes a null Pointer Exception. In either way it compiles successfully.
@CompileStatic
class A {
    Integer a

    A(Integer a) {
        this.a = a
    }

    void doSomething() {
        println(a.toString())
    }
}

def a = new A()
a.doSomething()