Groovy – Differences from Java Annotated
Things to be aware of
- semicolon is optional. Use them if you like (though you must use them to put several statements on one line).
- the return keyword is optional.
- you can use the this keyword inside static methods (which refers to this class).
- methods and classes are public by default.
- protected in Groovy is the equivalent of both package-protected and protected in Java. i.e. you can have friends in the same package – or derived classes can also see protected members.
- inner classes are not supported at the moment. In most cases you can use closures instead.
- the throws clause in method heads is not checked by the Groovy compiler, because there is no difference between checked and unchecked exceptions.
Groovy – Tutorial 4 – Regular expressions basics Annotated
the simplest expression involving a regular expression uses the ==~ operator. So for example to match Dan Quayle’s spelling of ‘potato’:
"potatoe" ==~ /potatoe/