I am the first to admit, I do not write scripts very 'Groovily'. It looks more like Java that uses some nice closures when convenient (but, boy are those /really/ convenient). So I am sure that if I stuck to a more Groove like style I would not run into these problems but today I wrote a simple script. I put a bunch of variables at the top of the script and ran it and --- Whoops I tripped over a
groovy.lang.MissingPropertyException: No such property: for class
exception.Turns out, in a Groovy script, variables that are not defined within methods /cannot/ have either an explicit type or a
def
. This is easy to fix, of course. Just let Groovy handle the duck typing or turn the script into a class but still, a little surprising.
No comments:
Post a Comment