CHAPTER 2 NUMBERS AND EXPRESSIONS

In this chapter, we are concerned with how we manipulate basic numeric values in Groovy. When doing so, we must be especially conscious that Groovy has been constructed as an object-oriented language. This means that everything in Groovy is ultimately an object—an instance of some class. For example, we are all familiar with the integer value 123. In Groovy, this is actually an object instance of the class Integer. To make an object do something, we know that we must invoke one of the methods declared in its class. Hence, to obtain the absolute value of such an integer, the Groovy environment invokes the method abs with the expression 123. abs (). Equally, to ask 123 for the value that follows it (124), the ...

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.