Record[...Ts]
Stores an immutable sequence of positional items and symbol-keyed items.
Records keep their items in order, and a key may repeat. A lookup finds the latest value for a key. Keys are read by indexing, not as fields:
A variadic capture such as ...rest binds a record of the remaining
arguments. To produce a changed record, spread the old record into a new one:
Inherits from: Iterable[Tuple[Sym | Int, Value]]
Implements: Index[{...Ts}], Spread[{...Ts}], Unpack[{...Ts}]
Constructor
Record source
Builds a record from one spreadable source of key-value pairs.
Integer keys counting up from 0 become positional items, as when
spreading a dict.
The lowercase record factory instead builds a record from its arguments.
Errors
Raises TypeError for any other key that is not a symbol.
Methods
(iter)()
Iterates record items as [key, value] pairs in order. A positional item's
key is its position.
(unpack)()
Unpacks record items by position and symbol.
get[D = nil] key … -> (Value | D)
Gets the value for a symbol or position, with an optional default.
Parameters
| Name | Type | Description |
|---|---|---|
key |
(Int | Sym) |
|
:default? |
D |
|
:else? |
(() -> D) |
len() -> Int
Number of items, counting each instance of a repeated key.