A dictionary is a collection of mappings from one object to another object. The default Dict implementation will use hashing for this.

Mimics
Inactive cells
Active cells
Specs
Inactive cells (details)
kind = "Dict"
Active cells (details)
+(...)

nil

==(other)

returns true if the left hand side dictionary is equal to the right hand side dictionary.

===(other)

nil

method(other, 
  if(self same?(
      {}), 
    Reflector other:mimics?(cell(:other), 
      {}), 
    bind(rescue(Condition Error, fn(c, false)), 
      self ==(
        other))))
?&(...)

if this dict is non-empty, returns the result of evaluating the argument, otherwise returns the dict

macro(
  argCount = call arguments length 
  cond(
    argCount ==(
      1), 
    
    theCode = call arguments [](
        0) 
    
    unless(empty?, 
      call argAt(0), 
      self), 
    error!(Condition Error Invocation NoMatch, message: call message, context: call currentContext)) 
  )
?|(...)

if this dict is empty, returns the result of evaluating the argument, otherwise returns the dict

macro(
  argCount = call arguments length 
  cond(
    argCount ==(
      1), 
    
    theCode = call arguments [](
        0) 
    
    if(empty?, 
      call argAt(0), 
      self), 
    error!(Condition Error Invocation NoMatch, message: call message, context: call currentContext)) 
  )
[](...)

nil

[]=(key, value)

takes two arguments, the key of the element to set and the value to set it too. returns the value set

addKeysAndValues(keys, values)

zips the keys and the values together into this dict. note that neither keys nor values need to be lists. you can use anything that is iterable with index.

method(keys, values, 
  keys each(i, k, 
    self [](k) = values [](i)) 
  self)
at(key)

takes one argument, the key of the element to return. if the key doesn't map to anything in the dict, returns the default value

each([indexOrArgOrCode] nil, [argOrCode] nil, [code] nil)

takes either one or two or three arguments. if one argument is given, it should be a message chain that will be sent to each object in the dict. the result will be thrown away. if two arguments are given, the first is an unevaluated name that will be set to each of the entries in the dict in succession, and then the second argument will be evaluated in a scope with that argument in it. if three arguments is given, the first one is an unevaluated name that will be set to the index of each element, and the other two arguments are the name of the argument for the value, and the actual code. the code will evaluate in a lexical context, and if the argument name is available outside the context, it will be shadowed. the method will return the dict. the entries yielded will be mimics of Pair.

empty?()

returns true if this dict is empty, false otherwise

hash()

returns a hash for the dictionary

inspect()

Returns a text inspection of the object

key?(key)

takes one argument, the key to check if it is in the dict.

keys()

Returns all the keys of this dict

merge(+pairsAndDicts, +:keywordPairs)

creates a new Dict from the arguments provided, combined with the values in the receiver. the arguments provided will override those in the receiver. the rules for arguments are the same as for dict, except that dicts can also be provided. all positional arguments will be added before the keyword arguments.

mergeWith(...)

merges this dictionary with the first argument using different strategies defined by the second to fourth arguments

macro(
  argCount = call arguments length 
  cond(
    argCount ==(
      1), 
    
    other = call argAt(
        0) 
    
    self merge(other), 
    argCount ==(
      2), 
    
    other = call argAt(
        0) 
    theCode = call arguments [](
        1) 
    
    theCode = theCode deepCopy 
    rhsName = genSym 
    theCode last <<(message(rhsName)) 
    combined = {} 
    other each(kv, 
      if(self key?(kv key), 
        call ground cell(rhsName) = kv value 
        combined [](kv key) = theCode evaluateOn(call ground, self [](kv key)), 
        combined [](kv key) = kv value)) 
    self merge(combined), 
    argCount ==(
      3), 
    
    other = call argAt(
        0) 
    lhsName = call arguments [](
        1) 
    theCode = call arguments [](
        2) 
    
    theCode = theCode deepCopy 
    rhsName = genSym 
    theCode last <<(message(rhsName)) 
    combined = {} 
    other each(kv, 
      if(self key?(kv key), 
        call ground cell(lhsName) = self [](kv key) 
        call ground cell(rhsName) = kv value 
        combined [](kv key) = theCode evaluateOn(call ground), 
        combined [](kv key) = kv value)) 
    self merge(combined), 
    argCount ==(
      4), 
    
    other = call argAt(
        0) 
    lhsName = call arguments [](
        1) 
    rhsName = call arguments [](
        2) 
    theCode = call arguments [](
        3) 
    
    lexicalCode = LexicalBlock createFrom(list(lhsName, rhsName, theCode), call ground) 
    combined = {} 
    other each(kv, 
      if(self key?(kv key), 
        combined [](kv key) = lexicalCode(self [](kv key), kv value), 
        combined [](kv key) = kv value)) 
    self merge(combined) 
    , 
    error!(Condition Error Invocation NoMatch, message: call message, context: call currentContext)) 
  )
notice()

Returns a brief text inspection of the object

seq()

returns a new sequence to iterate over this dictionary

size()

Returns the number of pairs contained in this dict.

withDefault(defaultValue)

takes one argument, that should be a default value, and returns a new mimic of the receiver, with the default value for that new dict set to the argument