O'Reilly logo

Groovy Programming by John Savage, Kenneth Barclay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required