Types

ArrLike

Parent type for user-defined types with array-like behaviour. Use in cases when you would like to inherit from built-in Arr. Inheriting from built-ins is not possible for now.

Attributes

arr_like_attr

name of the attribute that holds the underlying array, defaults to "items"

items

default attribute for the underlying array

Parent types

Direct children types

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)
	...
}

Methods

[](al:ArrLike, idx:Int)
Set element in the underlying array.
[]=(al:ArrLike, idx:Int, x:Any)
Get element from the underlying array.
Bool(al:ArrLike)
Call Bool() on the underlying array.
each(al:ArrLike, cb:Fun)
Call cb for each element in the underlying array.
init(al:ArrLike, attr:Str=items)
ArrLike constructor
len(al:ArrLike)
Get length of the underlying array.
push(al:ArrLike, val:Any)
Push an element to the underlying array.
without(ds:ArrLike, without_elt:Any)
Get new DelimStr without the given element