Iter type

Iterator. Parent type for all specific iterator types.

Direct children types

ArrIter
Arr (array) iterator.
ConstIter
Iterator that returns given value forever.
FilterIter
EXPERIMENTAL! Do not use!
FunIter
EXPERIMENTAL! Do not use!
HashIter
EXPERIMENTAL Hash iterator.
MapIter
EXPERIMENTAL! Do not use!
RangeIter
Iterates over a Range

Constructors

Iter(i:Iter) Source: autoload/Iter.ngs:92
Supports "for i in existing_iterator". Useful if you want to have a reference to the Iter for any reason.

Automatically called by NGS for syntax

for my_var in something { ... }

Returns

i

Example

# Prints 0, 2, ...
for i in my_iter=Iter(10) {
  echo(i)
  my_iter.drop(1)
}
Iter(f:Fun) Source: autoload/Iter.ngs:190
Undocumented
Iter(r:NumRange) Source: autoload/Iter.ngs:241
Create Iter from NumRange
Iter(n:Int) Source: autoload/Iter.ngs:244
Create Iter from Int
Iter(arr:Arr) Source: autoload/Iter.ngs:291
Calls ArrIter constructor.

Returns

ArrIter

Example

i = Iter([10, 20, 30])
Iter(h:Hash) Source: autoload/Iter.ngs:331
Undocumented
Iter(rd:ResDef) Source: autoload/Res.ngs:114
EXPERIMENTAL! Do not use!

Methods

drop(i:Iter, n:Int) Source: autoload/Iter.ngs:77
Fetch and drop next n values from iterator i.

Example

i = Iter([10,20,30])
drop(i, 1)
echo(i.next())
# Output: 20
each(i:Iter, cb:Fun) Source: autoload/Iter.ngs:98
Calls cb with each element from i

Returns

i

Example

Iter(10).each(echo)  # Prints 0 to 9
filter(i:Iter, predicate:Fun) Source: autoload/Iter.ngs:181
EXPERIMENTAL! Do not use!
init(i:MapIter, upstream_iter:Iter, mapper:Fun) Source: autoload/Iter.ngs:111
EXPERIMENTAL! Do not use!
init(i:FilterIter, upstream_iter:Iter, predicate:Any, invert_predicate:Bool=false) Source: autoload/Iter.ngs:129
EXPERIMENTAL! Do not use!
map(i:Iter, mapper:Fun) Source: autoload/Iter.ngs:122
EXPERIMENTAL! Do not use!
reject(i:Iter, predicate:Fun) Source: autoload/Iter.ngs:183
EXPERIMENTAL! Do not use!
take(i:Iter, n:Int) Source: autoload/Iter.ngs:82
Fetch and convert to array next n values from iterator i.

Example

i = Iter([10,20,30])
echo(i.take(2))  # Output: [10,20]
throw_if_no_next(i:Iter) Source: autoload/Iter.ngs:69
Private method of Iter.ngs, will be hidden in future.