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: 8
Eachable1
Eachable which each() calls the callback with one argument
Direct subtypes: 18

Methods

Bool(i:ArrIter) Source: autoload/globals/Iter.ngs:302
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/globals/Iter.ngs:292
ArrIter constructor.

Example

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

Returns

Any
peek(i:ArrIter) Source: autoload/globals/Iter.ngs:317
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/globals/Iter.ngs:298
Textual representation of ArrIter.

Returns

Str