Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed spaces

...

This will execute the autogenerated main(String[] args) method in the bytecode which instantiates the Foo class, which extends the 

link
Script
Script
1http://groovy.codehaus.org/apidocs/groovy/lang/Script.html
class  class and then call its run() method. You may also use this class directly in Java code, passing in variables to the script.

...

There's no need to use a Binding if you don't want to; Foo will have a no-argument constructor as well.  Though using a Binding you can easily pass in variables. After the end of the script any variables created will be in the Binding for you to access in Java.

...

If you just want to write some simple scripts and need some simple functions you can declare functions without writing a class. 
One difference from normal class-based groovy is that the def keyword is required to define a function outside of a class.

Here's an example of a simple script with a function.  Note that if ever you need things like static or instance variables and so forth then maybe its time to actually write a class (smile)

...