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

Any

Example

h = {"a": 1}
h["a"]  # 1
h["b"]  # KeyNotFound exception thrown
[](al:ArrLike, idx:Int) Source: stdlib.ngs:718
Set element in the underlying array.
[](hl:HashLike, k:Any) Source: stdlib.ngs:777
Get value by key. Throws KeyNotFound.

Automatically called by NGS for syntax

your_hashlike[k]
[](arr:Arr, idx:Int) Source: stdlib.ngs:2037
Get array element by index from the end (negative indexes handler). Throws IndexNotFound if abs(idx) > len(arr).

Parameters

idxNegative index

Example

[10,20,30][-1]  # 30
[](arr:Arr, r:NumRange) Source: stdlib.ngs:2049
Get array elements at specified indexes. Indexes specified by NumRange.

Parameters

rNumRange with negatve .end

Returns

Arr

Example

[10,20,30,40][1..-1]  # [20,30]
[](arr:Arr, r:PredRange) Source: stdlib.ngs:2098
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:2145
Get array elements at specified indexes.

Parameters

arrArray to pick items from
indexesIndexes of items to pick

Returns

Arr

Example

[10,20,30,40][[0,3]]  # [10, 40]
[](s:Str, i:Int) Source: stdlib.ngs:3434
Get given character (currently byte) of the string

Parameters

sOriginal string
iIndex of the character to return

Example

"abc"[0]  # "a"
[](s:Str, i:Int) Source: stdlib.ngs:3444
Get given character (currently byte) of the string (negative indexes handler). Throws IndexNotFound if abs(i) > len(s).

Parameters

sOriginal string.
iNegative index of the character to return

Example

"abc"[-1]  # "c"
[](s:Str, r:NumRange) Source: stdlib.ngs:3458
Get a substring. Indexes in s are specified by NumRange.

Parameters

sOriginal string
rNumRange with negatve .end

Returns

Str

Example

"(Look ma, no parens)"[1..-1]  # "Look ma, no parens"
[](ms:MatchSuccess, idx:Int) Source: stdlib.ngs:5693
Convenience method to access matches in MatchSuccess

Example

("abc" ~ /a(.)c/)[1]  # "b"
[](s:Str, r:RegExp) Source: stdlib.ngs:5874
Get substring of a string that corresponds to first match of given regular expression

Example

"x10ab20c30y"[/[0-9]+/]  # "10"
[](mp:MethodParams, k:Str) Source: autoload/MethodParams.ngs:29
Get named parameter