Skip to content

Instantly share code, notes, and snippets.

@juandiegoh
Last active August 29, 2015 14:13
Show Gist options
  • Save juandiegoh/628396ea6c39a58ae5cb to your computer and use it in GitHub Desktop.
Save juandiegoh/628396ea6c39a58ae5cb to your computer and use it in GitHub Desktop.
Groovy: dynamically change static method implementation
class StaticClass {
static def hello() {
println "hello"
}
}
StaticClass.hello() // prints "hello"
StaticClass.metaClass.static.hello = { println "bye" }
StaticClass.hello() // prints "bye"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment