[Pkg-tcltk-devel] Bug#993388: Bug#993388: tcl8.6: nested dicts: with lappend you can duplicate and than remove intermediate values
Davide Prina
davide.prina at gmail.com
Fri Sep 3 19:43:50 BST 2021
Hi Sergei,
On 31/08/21 18:29, Sergei Golovan wrote:
> As far as I can see, there's nothing wrong with Tcl here.
I'm very sorry for my mistakes :-(
Thanks for your explanation.
On nested dict there are very few documentation and, at first, I don't
have fully understand the examples on the man page. So I have search and
found a site that tell that the only way to modify a nested dict is with
"dict with"... and I have make some mistakes...
I have try to understand dict better and found that you can modify
nested dict also with "dict set"
I think now I have understand nested dict.
# create a nested dict
% set MyDict [dict create l0a 1 l0b1 1 l0c {l1a 2 l1b {l2a {l3a 4 l3b 4}
l2b 3} l1c 2 l1d 2} l0d 1 l0e 1]
l0a 1 l0b1 1 l0c {l1a 2 l1b {l2a {l3a 4 l3b 4} l2b 3} l1c 2 l1d 2} l0d 1
l0e 1
# you can add new values or update with dict set
% dict set MyDict l0c l1b l2d {l3A 4 l3B 4}
l0a 1 l0b1 1 l0c {l1a 2 l1b {l2a {l3a 4 l3b 4} l2b 3 l2d {l3A 4 l3B 4}}
l1c 2 l1d 2} l0d 1 l0e 1
# you can append new value with dict lappend and dict with
% dict with MyDict l0c l1b {dict lappend l2d l3C 4}
l3A 4 l3B 4 l3C 4
% echo $MyDict
l0a 1 l0b1 1 l0c {l1a 2 l1b {l2a {l3a 4 l3b 4} l2b 3 l2d {l3A 4 l3B 4
l3C 4}} l1c 2 l1d 2} l0d 1 l0e 1
You can close this bug report.
Ciao
Davide
More information about the Pkg-tcltk-devel
mailing list