type

Dict

@Js
const mixin Dict

Dict is an immutable map of name/value pairs.

methods

_id
each

Iterate through the name/value pairs

eachWhile

Iterate through the name/value pairs until the given function returns non-null, then break the iteration and return resulting object.

get

Get the value for the given name or def if name not mapped

has

Return true if this dictionary contains given name

isEmpty

Return if the there are no name/value pairs

map

Create a new instance of this dict with the same names, but apply the specified closure to generate new values.

missing

Return true if this dictionary does not contain given name

trap

Get the value mapped by the given name.

Slot Details

_id

abstract Ref _id()

each

abstract Void each(|Obj,Str| f)

Iterate through the name/value pairs

eachWhile

abstract Obj? eachWhile(|Obj,Str->Obj?| f)

Iterate through the name/value pairs until the given function returns non-null, then break the iteration and return resulting object. Return null if function returns null for every name/value pair.

get

@Operator
abstract Obj? get(Str name, Obj? def := null)

Get the value for the given name or def if name not mapped

has

abstract Bool has(Str name)

Return true if this dictionary contains given name

isEmpty

abstract Bool isEmpty()

Return if the there are no name/value pairs

map

abstract This map(|Obj,Str->Obj| f)

Create a new instance of this dict with the same names, but apply the specified closure to generate new values.

missing

abstract Bool missing(Str name)

Return true if this dictionary does not contain given name

trap

abstract override Obj? trap(Str name, Obj?[]? args := null)

Get the value mapped by the given name. If it is not mapped to a non-null value, then throw an UnknownNameErr.