type

Dict

@Js
const mixin Dict

Dict is a map of name/value pairs. Create instances via XetoEnv.dict.

methods

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

missing

Return true if this dictionary does not contain given name

spec

Specification of this dict or sys::Dict if generic.

trap

Get the value mapped by the given name.

Slot Details

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

missing

abstract Bool missing(Str name)

Return true if this dictionary does not contain given name

spec

abstract Spec spec()

Specification of this dict or sys::Dict if generic.

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.