Like all OO languages, Groovy does not have the concept of "global" in itself (unlike, say, BASIC, Python or Perl).
If you have several methods that should use the same variable, use the field:
class Foo { def a; def foo() { a = 1; } def bar() { print a; } }
Aaron Digulla Jun 10 '11 at 11:50 2011-06-10 11:50
source share