type

Dict

@Js
const mixin Dict : Dict

Dict is a map of name/value pairs. It is used to model grid rows, grid meta-data, and name/value object literals. Dict is characterized by:

  • names must match Etc.isTagName rules
  • values should be one valid Haystack kinds
  • get [] access returns null if name not found
  • trap -> access throws exception if name not found

Also see Etc.emptyDict, Etc.makeDict.

methods

dis

Get display string for dict or the given tag.

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 the given name is mapped to a non-null value.

id

Get the id tag as a Ref or raise CastErr/UnknownNameErr

isEmpty

Return if the there are no name/value pairs

missing

Return true if the given name is not mapped to a non-null value.

spec

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

toStr

Return string for debugging only

trap

Get the value mapped by the given name.

Slot Details

dis

virtual Str? dis(Str? name := null, Str? def := "")

Get display string for dict or the given tag. If name is null, then return display text for the entire dict using Etc.dictToDis. If name is non-null then format the tag value using its appropiate toLocale method. If name is not defined by this dict, then return def.

each

abstract override Void each(|Obj,Str| f)

Iterate through the name/value pairs

eachWhile

abstract override 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 override Obj? get(Str name, Obj? def := null)

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

has

abstract override Bool has(Str name)

Return true if the given name is mapped to a non-null value.

id

virtual Ref id()

Get the id tag as a Ref or raise CastErr/UnknownNameErr

isEmpty

abstract override Bool isEmpty()

Return if the there are no name/value pairs

missing

abstract override Bool missing(Str name)

Return true if the given name is not mapped to a non-null value.

spec

virtual override Spec spec()

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

toStr

virtual override Str toStr()

Return string for debugging only

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.