Other Groovy Features
Have barely scratched the surface
- Metaprogramming
- Adding methods to classes at runtime (or changing them)
- Domain Specific Languages and Builders
- By implemented by overriding
MetaClass.invokeMethod or MetaClass.invokeMissingMethod an object implements methods
- Really easy XML processing (XML Slurper)
- Implicit getters and setters
- Getters and setters automatically defined for every field (saves typing, you can change them later.) Referencing a field invokes the getter, assignment invokes the setter.
- An object can be treated as a map
- GDK
- Really useful functionality added to everything in the JDK
(executing a closure on each element in a Collection, grepping thruogh a collection, dumping objects to strings, etc
- GStrings
- Perl/Awk Style Strings Interpolation
- Duck Typing
- Deciding how to handle an object based on what methods it supports.
- Generalized Switch statement
- You can
switch on any object. switch uses the Object.isCase method.
- Built in Regular Expressions (like Perl)
- Operator Overloading
- Yay! We can redefine
+= again!
Next