APPENDIX C MORE ON NUMBERS AND EXPRESSIONS

The Groovy interpreter plays an important role in the evaluation of an expression. For example, in Chapter 2, we discussed operators in the context of the evaluation expressions such as 123 + 456. The assumption made was that it was possible to send the message plus to an Integer object. This is not strictly true because there is no class in the Groovy environment with that method. The Groovy interpreter recognizes that two integers are being added and arranges matters so that it appears that the method call 123.plus (456) is executed. The attraction of this approach is that the core Java classes such as Integer, on which Groovy is built, are unchanged, yet they give us a more Groovy-like functionality. ...

Get Groovy Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.