Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why groovyConsole supports `def name = "Neo"` while groovysh does not [duplicate]

Following is 2 lines of code:

def name = "Neo"
println name

If I execute it in groovysh, I will get Unknown property: name error. If I execute it in groovyConsole, everything goes on well.

like image 374
Neo Avatar asked Jan 23 '15 16:01

Neo


1 Answers

If you want features from Groovy 2.4.0 you can use

:set interpreterMode true to see a difference. :)

groovy:000> def a = 10
===> 10
groovy:000> a
Unknown property: a
groovy:000> :set interpreterMode true
groovy:000> a
Unknown property: a
groovy:000> def b = 100
===> 100
groovy:000> b
===> 100
groovy:000>
like image 67
dmahapatro Avatar answered Oct 04 '22 01:10

dmahapatro