I'm only fairly recently working with 8.5 on all my platforms, and I
am trying to start using dictionaries in new code. Still trying to
get my head around some of the implications..
In particular, consider this code:
#!/usr/bin/tclsh8.5
dict set new_dict my_inventory keychains 11
dict set new_dict my_inventory watchfobs 31
dict set new_dict my_inventory hatpins 42
Now suppose I buy another watchfob? I figured that
dict incr new_dict my_inventory watchfobs
would do the trick, but instead I get:
expected integer but got "keychains 11 watchfobs 31 hatpins 42"
while executing
"dict incr new_dict my_inventory watchfobs"
(file "/tmp/doit" line 8)
Of course this works:
set wf [dict get $new_dict my_inventory watchfobs]
incr wf
dict set new_dict my_inventory watchfobs $wf
but it seems cumbersome. If I can "set" a value, shouldn't I be
able to "incr" it? Is there a better way to do the increment?
--
------
columbiaclosings.com
What's not in Columbia anymore..