Prev | Current Page 117 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


This is because the List type provides less of the heavier functionality such as directly accessing the
values it contains using indexes. Instead, the List must be examined in a loop using an iterator or
Chapter 3: Learning the Basics
47
through one of its available methods, as trying to access the indexes of a List will result in a compiler
error. Loops and iterators are covered in the next chapter.
Surprisingly, the List type supports quite a differing assortment of methods over the Array type. The
List ??™ s primary use is as a container for objects that are not wholly independent of one another, and
whose values are only of use when read or manipulated as a group. To this end, the methods of the List
type are oriented toward batch processing and iteration of its contained values. While the length and
remove methods exist in the List type in the same fashion as the Array, some methods are altogether
different.
Table 3 - 4 lists the methods available to a List object.
Table 3-4
List Field Description
length : Int Returns the number of items in the List; it is
read-only.


Pages:
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129