Grails:println只能在有时候或者其他的东西上运行 [英] Grails: println only works sometimes or something

查看:191
本文介绍了Grails:println只能在有时候或者其他的东西上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ExpandoMetaClass.enableGlobally()

Integer.metaClass.precision = { - > return 1}
println 3.precision()
printlnrofl
println 15.precision()

并且它符合我的预期,运行应用程序打印:

  1 
rofl
1

但是如果我拿出 printlnrofl它不会打印第二个。它只是打印一个1没有rofl ...跆拳道?



同样,因为这对我没有任何意义,这个代码:

  ExpandoMetaClass.enableGlobally()

Integer.metaClass.precision = { - > return 1}
println 3 .precision()
// printlnrofl
println 15.precision()

print:

  1 


解决方案

这是一个ubuntu默认设置,与JVM无关。如果它们相同,控制台将不会重复行。当我记得如何关闭它时,会更新这个答案。


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

解决方案

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.

这篇关于Grails:println只能在有时候或者其他的东西上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆