July 2013
Intermediate to advanced
370 pages
8h 27m
English
The GDK extensions go beyond the Object class. Several other JDK classes and interfaces have been enhanced in the GDK. Again, the list is vast and we’ll look at only a subset of extensions in this section. These are the extensions we’re likely to put to regular use.
We can use the Range object as an index on all the array types (for the syntax for creating arrays, see Different Syntax for Creating Primitive Arrays), such as int[], double[], and char[]. Here’s how we can access contiguous values in an int array using the range of index:
| ExploringGDK/Array.groovy | |
| | int[] arr = [1, 2, 3, 4, 5, 6] |
| | |
| | println arr[2..4] |
The output shows the values in the given range:
| | [3, 4, 5] |
We’re already ...
Read now
Unlock full access