Types

ArrIter

Arr (array) iterator.

Parent types

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']

Methods

Bool(i:ArrIter)
Check whether there are more array elements to iterate over. true: next() will return next element. false: next() will throw NoNext
init(i:ArrIter, arr:Arr)
ArrIter constructor.
next(i:ArrIter)
Get value of the next element of the array iterated over.
peek(i:ArrIter)
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().
Str(i:ArrIter)
Textual representation of ArrIter.