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: 16
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:1532
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:1503
Set element in the underlying array.
- []=(al:ArrLike, idx:Int, x:Any) Source: stdlib.ngs:1506
Get element from the underlying array.
- Arr(al:ArrLike) Source: stdlib.ngs:1520
Get the underlying array
- Bool(al:ArrLike) Source: stdlib.ngs:1516
Check whether al has any elements.
- collector(al:ArrLike, body:Fun) Source: stdlib.ngs:1536
Defines collector { ... collect(...) ... } behaviour for ArrLike. Very similar to collector for Arr. See collector(Arr,Fun).
- each(al:ArrLike, cb:Fun) Source: stdlib.ngs:1513
Call cb for each element in the underlying array. Returns
al
- get(al:ArrLike, idx:Int, dflt:Any) Source: stdlib.ngs:1509
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:1479
Undocumented
- init(al:ArrLike, field:Str=null) Source: stdlib.ngs:1485
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:1490
Undocumented
- init(al:ArrLike, arr:Arr) Source: stdlib.ngs:1495
Undocumented
- join(al:ArrLike, s:Str) Source: stdlib.ngs:1527
Join items to a single string using given separator s Returns
Str
- len(al:ArrLike) Source: stdlib.ngs:1500
Get length of the underlying array.
- push(al:ArrLike, val:Any) Source: stdlib.ngs:1523
Push an element to the underlying array.
- Str(a:ArrLike) Source: stdlib.ngs:1546
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"