[] multimethod
Methods
- [](lib:CLib, symbol:Str)
Unfinished feature. Don't use!
- [](arr:Arr, range:NumRange)
Get array elements at specified indexes. Returns
Arr
- [](arr:Arr, idx:Int)
Get element at the given index or throw IndexNotFound if the index is out of range (element at the given index does not exist). Returns
Any
- [](s:Str, range:NumRange)
Get substring Example
"abcd"[1..3] # "bc"
- [](h:Hash, k:Any)
Get hash value by key. Throws KeyNotFound. Returns
AnyExample
h = {"a": 1} h["a"] # 1 h["b"] # KeyNotFound exception thrown
- [](al:ArrLike, idx:Int) Source: stdlib.ngs:657
Set element in the underlying array.
- [](hl:HashLike, k:Any) Source: stdlib.ngs:693
Get value by key. Throws KeyNotFound. Automatically called by NGS for syntax
your_hashlike[k]
- [](arr:Arr, idx:Int) Source: stdlib.ngs:1902
Get array element by index from the end (negative indexes handler). Throws IndexNotFound if abs(idx) > len(arr). Parameters
idx Negative index Example
[10,20,30][-1] # 30
- [](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]
- [](arr:Arr, r:PredRange) Source: stdlib.ngs:1950
Extract array elements between the element that matches r.start and the element that matches r.end . Starting and ending elements are optionally included, depending on r.include_start and r.include_end . Example
%[a1 a2 b1 b2][/^a/../^b/] # ['a2'] %[a1 a2 b1 b2][/^a/.../^b/] # ['a1', 'a2', 'b1'] %[a1 a2 b1 b2][/^a/.../^x/] # IndexNotFound exception
- [](arr:Arr, indexes:Arr) Source: stdlib.ngs:1997
Get array elements at specified indexes. Parameters
arr Array to pick items from indexes Indexes of items to pick Returns
ArrExample
[10,20,30,40][[0,3]] # [10, 40]
- [](s:Str, i:Int) Source: stdlib.ngs:3289
Get given character (currently byte) of the string Parameters
s Original string i Index of the character to return Example
"abc"[0] # "a"
- [](s:Str, i:Int) Source: stdlib.ngs:3299
Get given character (currently byte) of the string (negative indexes handler). Throws IndexNotFound if abs(i) > len(s). Parameters
s Original string. i Negative index of the character to return Example
"abc"[-1] # "c"
- [](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"
- [](my:MatchY, idx:Int) Source: stdlib.ngs:5381
Convenience method to access matches in MatchY Example
("abc" ~ /a(.)c/)[1] # "b"
- [](s:Str, r:RegExp) Source: stdlib.ngs:5562
Get substring of a string that corresponds to first match of given regular expression Example
"x10ab20c30y"[/[0-9]+/] # "10"