Method Iterator()->`+=()
- Method `+=
Iterator() += steps
- Description
Advance this iterator the specified number of steps and return it. The amount may be negative to move backwards. If the iterator doesn't support backward movement it should throw an exception in that case.
- Note
foreach calls this function with a step value of
1
if next() doesn't exist for compatibility with Pike 7.6 and earlier.- Note
foreach will call this function even when the the iterator has more than one reference. If you want to loop over a copy of the iterator, you can create a copy by adding
0
(zero) to it:Iterator iterator; ... foreach(iterator+0; mixed index; mixed value) { ... }
- Note
Even though this function is sufficient for foreach to advance the iterator, next() is the preferred API. next() has the additional advantage of not being an lfun, so it is possible to advance the iterator by hand.
- See also