P2Hash

Implements a dictionary that stores objects indexed by keys. The keys are string types.

Factory Messages

Operational Messages

at: aKey

Answer the value associated with the given key. Throws a Ponder2ArgumentException error if not found.

at: aKey ifAbsent: aBlock

Answer the value associated with the given key. If not found evaluate block (with no arguments) and return its result

at: aKey put: anObject

Answer anObject. Store anObject in the table with aKey. If aKey already exists the previous value is overridden.

collate: aBlock

Takes a block and executes the block once for each entry in the hash. The arguments to the block are the name of the entry and the value of the entry. The result of each block is collated and returned in an array.

do: aBlock

Takes a block and executes the block once for each entry in the hash. The arguments to the block are the name of the entry and the value of the entry. Answers with the receiver.

has: aKey

Answer true if the given key exists otherwise false

remove: aKey

Answer the value associated with the given key and remove it from the table. Answer null if it is not found. TODO Should fail if not found