Prev | Current Page 110 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

This is because the location will always be 0.
When adding values to the beginning of an Array, all other values contained in the Array are moved up
by one, so the previous starting value will now exist at location 1.
The equivalent pop method for removing and returning values from the beginning of an Array is called
shift :
var shiftedValue : Int = myArray.shift();
Adding and Removing Values from the Middle of an Array
Two main methods are provided by haXe for removing values from the middle of an Array: remove and
splice . Both methods perform the item removal in very different ways, and are equally useful.
Part I: The Core Language
44
Remove()
The remove method is used to seek out and remove an item with a given value. The method takes only
one parameter: the value to match and remove. Starting at the beginning of the Array, the method
searches for the given value. When it finds it, the search stops and the value is removed causing all items
that exist after it in the Array to move down by one location:
var isFound : Bool = myArray.


Pages:
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122