Version 5 of dict create

Updated 2011-08-16 20:33:15 by dkf
dict create ?key value? ?key value? ...

Creates a dictionary out of a sequence of keys and values passed as individual arguments. If a key is repeated, it shall be in the resulting dictionary in a location that corresponds to the first time that key occurs, but shall use the last value for that key.


Empty Dictionaries

Recently on comp.lang.tcl, someone asked how to create an empty dict, and the reply was, basically,

set e [dict create]

Certainly there are other ways to set the variable to the equivalent of an empty dict

set e ""
set e [list]
set e {}
set e []

However, these latter methods don't convey to the reader of the program that you are expecting to perform dict operations on the variable. Probably not a big deal, though.

DKF: They're all likely to have exactly the same effect in practice anyway: storing a shared empty object in e.


See Also