NumRange type
Direct parent types
- Range
A range Direct subtypes: 2
- Eachable1
Eachable which each() calls the callback with one argument Direct subtypes: 16
Methods
- [](arr:Arr, range:NumRange)
Get array elements at specified indexes. Returns
Arr
- [](s:Str, range:NumRange)
Get substring Example
"abcd"[1..3] # "bc"
- [](arr:Arr, r:NumRange) Source: stdlib.ngs:1914
Get array elements at specified indexes. Indexes specified by NumRange. Parameters
r NumRange with negatve .end Returns
ArrExample
[10,20,30,40][1..-1] # [20,30]
- [](s:Str, r:NumRange) Source: stdlib.ngs:3313
Get a substring. Indexes in s are specified by NumRange. Parameters
s Original string r NumRange with negatve .end Returns
StrExample
"(Look ma, no parens)"[1..-1] # "Look ma, no parens"
- []=(arr:Arr, range:NumRange, replacement:Arr)
Set array elements at specified indexes. Returns
replacement
- []=(s:Str, range:NumRange, replacement:Str)
Change substring Returns
replacementExample
s="abcd"; s[1..3]="X"; s # "aXd"
- each(r:NumRange, cb:Fun) Source: stdlib.ngs:1215
Iterates over the elements of r, passing each in turn to cb. Parameters
cb Function to be called with values from r Returns
rExample
s=0 (1...10).each(F(i) { global s; s+=i }) echo(s) # Outputs: 55
- in(n:Int, r:NumRange) Source: stdlib.ngs:1227
Check whether the number is in range 10 in 10..20 # true 1 in 10..20 # false
- init(i:RangeIter, r:NumRange) Source: autoload/Iter.ngs:248
Initialize RangeIter. Will throw NotImplemented if r.start or r.step are not Int
- Iter(r:NumRange) Source: autoload/Iter.ngs:241
Create Iter from NumRange
- rand(r:NumRange) Source: stdlib.ngs:5936
Pick one random element from a range Returns
Any