ArrLike type
Example
type T(ArrLike) F Str(t:T) "<My array has ${len(t)} items totalling ${sum(t)}>" # Override one of the Arr methods a = T() a.push(10) a.push(20) echo(a) # <My array has 2 items totalling 30> # If you need init() you should have something like the following to allow ArrLike initialization: init(t:T) { super(t) ... }
Direct parent types
- Eachable1
Eachable which each() calls the callback with one argument Direct subtypes: 17
Direct children types
- AllOf
Should probably inherit from Set, not ArrLike.
- AnyOf
Should probably inherit from Set, not ArrLike.
- DelimStr
EXPERIMENTAL. Delimited string. Showing ArrLike usage.
- Lines
Array of strings which comprise a text which is treated as a unit for purposes of output (and maybe for other purposes later).
- Results
Results, an array-like of Result elements
- Threads
Threads
Methods
- .(al:ArrLike, s:Str) Source: stdlib.ngs:1927
Return array made of given field of each element of given array. Will throw KeyNotFound if any of the elements does not have the desired field. Use get() to handle missing field differently.
- [](al:ArrLike, idx:Int) Source: stdlib.ngs:1898
Set element in the underlying array.
- []=(al:ArrLike, idx:Int, x:Any) Source: stdlib.ngs:1901
Get element from the underlying array.
- Arr(al:ArrLike) Source: stdlib.ngs:1915
Get the underlying array
- Bool(al:ArrLike) Source: stdlib.ngs:1911
Check whether al has any elements.
- collector(al:ArrLike, body:Fun) Source: stdlib.ngs:1931
Defines collector { ... collect(...) ... } behaviour for ArrLike. Very similar to collector for Arr. See collector(Arr,Fun).
- each(al:ArrLike, cb:Fun) Source: stdlib.ngs:1908
Call cb for each element in the underlying array. Returns
al
- get(al:ArrLike, idx:Int, dflt:Any) Source: stdlib.ngs:1904
Get element at the given index or return dflt if the index is out of range (element at the given index does not exist). See get(Arr).
- init(al:ArrLike) Source: stdlib.ngs:1874
Undocumented
- init(al:ArrLike, field:Str=null) Source: stdlib.ngs:1880
Throws NotImplemented if field is specified Parameters
field DEPRECATED name of the field that holds the underlying array.
- init(al:ArrLike, e:Eachable1) Source: stdlib.ngs:1885
Undocumented
- init(al:ArrLike, arr:Arr) Source: stdlib.ngs:1890
Undocumented
- join(al:ArrLike, s:Str) Source: stdlib.ngs:1922
Join items to a single string using given separator s Returns
Str
- len(al:ArrLike) Source: stdlib.ngs:1895
Get length of the underlying array.
- push(al:ArrLike, val:Any) Source: stdlib.ngs:1918
Push an element to the underlying array.
- Str(a:ArrLike) Source: stdlib.ngs:1941
Convert ArrLike to a human-readable representation
- without(ds:ArrLike, without_elt:Any)
Get new DelimStr without the given element Example
DelimStr("/bin:/usr/bin:/usr/local/bin").without("/usr/bin").Str() # "/bin:/usr/local/bin"