June 2014
Intermediate to advanced
576 pages
19h 26m
English
It’s not always easy to find the information you want about Groovy, so we’ve incorporated a short reference here that includes useful information in an easily digested form. It focuses on two Groovy features: operator overloading and the extension methods that Groovy adds to the core Java class library.
Groovy allows you to support operators on your own classes, such as +, *, <<, and so on. The mechanism for this is straightforward: implement methods with specific names. If you want to support adding two matrices together with the + operator, you can implement plus():
class Matrix {
...
Matrix plus(Matrix other) {
...
}
}
Even if you don’t implement any of the operator methods yourself, ...
Read now
Unlock full access