Pike v8.0 release 1738

Method get_iterator()


Method get_iterator

Iterator get_iterator(object|array|mapping|multiset|string data)

Description

Creates and returns a canonical iterator for data.

Returns
data can have any of the following types:
object

If data is an object with lfun::_get_iterator defined then it's called in it to create the iterator.

If data is an object that lacks lfun::_get_iterator then it's assumed to already be an iterator object, and is simply returned.

array

If data is an array, an Array.Iterator object will be returned.

mapping

If data is a mapping, a Mapping.Iterator object will be returned

multiset

If data is a multiset, a Multiset.Iterator object will be returned

string

If data is a string, a String.Iterator object will be returned

Note

This function is used by foreach to get an iterator for an object.

See also

Iterator, lfun::_get_iterator