Hello, all
I tried to define a global variable in a Groovy script.
Section 1.1. of the "Semantics" documents says that one way
to define a variable is via its type, so I defined one in
the global scope of my script:
String test
void func()
{
println(test)
}
test = 'hello'
On 14.10.20 13:45, Anton Shepelev wrote:
[...]
String test
defienes a string property `test' or a string variable
`test', depending on context.
the context here is that of a method, so it is a local variable
I was now stuck and resorted
to an internet search, which brought up the followi
Hi,
I've been caught out by this in the past as well. It's actually quite
simple...
A Groovy Script like:
String test
void func(){
println(test)
}
test = 'hello'
func()
Gets compiled to a class as:
class MyScript extends Script {
def run() {
Str
Jochen Theodorou to Anton Shepelev:
> > String test
> >
> > void func()
> > {
> >println(test)
> > }
> >
> > test = 'hello'
> > func()
> >
> > Why, then, is `test' inaccessible from the function in
> > my script?
>
> because the method you defined is not nested in another
> method, instead it
Mariusz W:
> class Boo {
> def boo() {throw new UnsupportedOperationException("should override")}
> def foo() { println "foo"}
> }
>
> def a = [boo : {
> foo()
> }] as Boo
>
> a.boo()
As far as I can see (which is not a great distance away from
my nose), you are trying to construct an
On 14.10.20 17:01, Anton Shepelev wrote:
Jochen Theodorou to Anton Shepelev:
[...]
Frankly... for years we have been defending this position,
but now, with so much distance I actually really wonder
why we keep this.
Perhaps it would have helped if you had documented not only
language features
Anton,
> ...You cannot refer to the method of an object that has not yet been
> constructed.
As a matter of fact, you can. This darned Java “method-calling” lingo is
terribly misleading; we definitely should have sticked with Alan Kay's
“message-sending”, and there would be much less misunders