Skip to content

Instantly share code, notes, and snippets.

@int128
Created May 22, 2014 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save int128/af097d5d5a82bc6dd4b6 to your computer and use it in GitHub Desktop.
Save int128/af097d5d5a82bc6dd4b6 to your computer and use it in GitHub Desktop.
Adding static property on runtime
@groovy.transform.ToString
class A {
//static final int P = 100
int x
}
A.metaClass.P = 100
def a = new A()
a.with {
x = P
}
a // -> A(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment