ArrIter type

Arr (array) iterator.

Example

my_args = %[--switch val some other positional --sw2 val2]
i = Iter(my_args)

named = {}
positional = []

while i {
	t = i.next()
	m = t ~ Pfx('--')
	if m {
		named[m.after] = i.next()
	} else {
		positional.push(t)
	}
}

echo(named)
echo(positional)
# Output:
#   {switch=val, sw2=val2}
#   [some,other,positional]

Direct parent types

Iter
Iterator. Parent type for all specific iterator types.
Direct subtypes: 7
Eachable1
Eachable which each() calls the callback with one argument
Direct subtypes: 16

Methods

Bool(i:ArrIter) Source: autoload/Iter.ngs:306
Check whether there are more array elements to iterate over.

Returns

Bool. true: next() will return next element. false: next() will throw NoNext
init(i:ArrIter, arr:Arr) Source: autoload/Iter.ngs:296
ArrIter constructor.

Example

i = ArrIter([10, 20, 30])
next(i:ArrIter) Source: autoload/Iter.ngs:311
Get value of the next element of the array iterated over.

Returns

Any
peek(i:ArrIter) Source: autoload/Iter.ngs:321
Preview value of the next element of the array iterated over. Does not affect internal pointer which means it does not affect of value returned by next().

Returns

Any
Str(i:ArrIter) Source: autoload/Iter.ngs:302
Textual representation of ArrIter.

Returns

Str