More Metaprogramming

class Sample {
}

Sample.metaClass.static.blah = { -> println "this worked, too!" }
Sample.blah()
[bruce@kimura presentation]$ groovy test.groovy
this worked, too!



String.metaClass.foo = { -> println "Hi ${delegate}" }
  "Bruce".foo()

[bruce@kimura presentation]$ groovy test2.groovy
Hi bruce

This only works for code compiled by groovy compiler, not by java compiler
Next