I make a brand new grails project and put this in the bootstrap:
ExpandoMetaClass.enableGlobally()
Integer.metaClass.precision = {->return 1}
println 3.precision()
println "rofl"
println 15.precision()
And it does what I expect, run-app prints:
1
rofl
1
But if i take out the println "rofl"
it won't print that second one. It just prints one 1 without the rofl... WTF?
Again, becasue this doesn't make any sense to me, this code:
ExpandoMetaClass.enableGlobally()
Integer.metaClass.precision = {->return 1}
println 3.precision()
//println "rofl"
println 15.precision()
prints:
1
Mikey, I can't think of a reason why. Can you try in a different environment? I just tried this quickly under Groovy Version: 1.8.0 JVM: 1.6.0_20, Win7 and Grails 2 BootStrap and a Grails Controller action and sorry to say "it works on mine". So all I can think is that its somehow related to the version you are using or how it is setup. How are you running this?