1

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
  • 4,692
  • 10
  • 45
  • 73

2 Answers2

0

This is an ubuntu default setting and has nothing to do with JVM. The console won't repeat lines if they are the same. Will update this answer when I remember how to turn it off.

Mikey
  • 4,692
  • 10
  • 45
  • 73
0

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?

Steve
  • 1,457
  • 12
  • 25
  • What are you using the controller for? I have all the code in the bootstrap. Also I have upgraded my grails and groovy. Still not working. – Mikey Jan 17 '12 at 01:56
  • Just tried it in the controller for kicks but I tried Bootstrap for sure. I'm not sure on STS, are you running from STS or just command line or interactive? All I can think is to try from different places, but I'm guessing that is what you have trying for the last few hours. – Steve Jan 17 '12 at 04:43
  • Actually upgrading grails to 2.0 is kicking my ass. – Mikey Jan 17 '12 at 05:00
  • So I did grails upgrade on my project and its destroyed. Now I can't get anything grails 2.0 to run.... get ready for some other questions, SO!! – Mikey Jan 17 '12 at 05:01
  • Upgraded grails to 2.0 and groovy to 1.8, changed JVM from IcedTea 6 to Oracle 6 to Oracle 7. Same results. Tried on my work PC: win7 home jvm 6 grails 1.3.7 also same error. – Mikey Feb 11 '12 at 00:51