Method get_iterator()
- Method
get_iterator
Iteratorget_iterator(function(:void)|object|array|mapping|multiset|stringdata,mixed...args)- Description
Creates and returns a canonical iterator for
data.- Returns
datacan have any of the following types:objectIf
datais an object with lfun::_get_iterator defined then that function will be called with the argumentsargsto create the iterator.If
datais an object that lacks lfun::_get_iterator then it is assumed to already be an iterator object. In this caseargswill be ignored (note this behavior may be changed).The iterator object is then checked whether it has lfun::_iterator_next() in which case it will simply be returned. Otherwise an attempt to wrap it in a
CompatIteratorwill be performed.arrayIf
datais an array, an Array.Iterator object will be returned.function(:void)If
datais a function, a Function.Iterator object will be returned.mappingIf
datais a mapping, a Mapping.Iterator object will be returnedmultisetIf
datais a multiset, a Multiset.Iterator object will be returnedstringIf
datais a string, a String.Iterator object will be returned- Note
This function is used by
foreachto get an iterator for an object.- See also