ArrIter type
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: 17
Methods
- Bool(i:ArrIter)
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)
ArrIter constructor. Example
i = ArrIter([10, 20, 30])
- next(i:ArrIter)
Get value of the next element of the array iterated over. Returns
Any
- 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(). Returns
Any
- Str(i:ArrIter)
Textual representation of ArrIter. Returns
Str