Extracted from Pike v7.6 release 61 at 2005-12-30.
pike.ida.liu.se
[Top]
Iterator

Method Iterator()->`+=()


Method `+=

Iterator `+=(int 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.

foreach calls this function with a step value of 1.

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 an lfun, it is often beneficial to not declare it static, since code might want to advance the iterator by hand.