dict exists

Subcommand of dict. Tests whether a particular key exists in a dictionary (or nested set of dictionaries).

dict exists dict key ?key …?

This command does not return an error if dict isn't actually a dictionary.


There's a difference in behaviour between tclsh (ActiveTcl) and tclkitsh (tested with both 8.5.11):

set theDict [dict create one 1 two 2 three {3 x}]
puts [dict exists $theDict four]
puts [dict exists $theDict three 3]
puts [dict exists $theDict three 4]
puts [dict exists $theDict two y]; <=========== Difference between tclsh and tclkitsh

# tclkitsh8511 dicttest.tcl
0
1
0
missing value to go with key
    while executing
"dict exists $theDict two y"
    invoked from within
"puts [dict exists $theDict two y]"
    (file "dicttest.tcl" line 5)

# tclsh dicttest.tcl
0
1
0
0

DKF: That'll be a difference between versions due to Bug 3475264 .