Reputation: 3103
See the Tcl code below:
proc foo {} {
puts "env get is:[array get ::env "DODA" ]"
}
set env("DODA") bar
foo
exit
I would expect that the output would beenv get is:{DODA bar}
Instead, it returns just empty list for the array get, namely:env get is:
Any ideas what am I doing wrong? This is Tcl 8.5
Upvotes: 1
Views: 63
Reputation: 16428
In Tcl
, the arrays are associative arrays. With that, the double quotes and braces behave as separate entity when it comes to array's index.
% set user(name) dinesh
dinesh
% set user("name") DINESH
DINESH
% set user({name}) Dinesh
Dinesh
% parray user
user("name") = DINESH
user(name) = dinesh
user({name}) = Dinesh
% array size user
3
As you can see, the entries name
, "name"
, {name}
are different.
Now, in your case, you have created the index "DODA"
with double quotes.
% set env("DODA") bar
bar
% puts "env get is:[array get ::env \"DODA\" ]"
env get is:{"DODA"} bar
%
Or otherwise,
% set env(DODA) bar
bar
% puts "env get is:[array get ::env DODA ]"
env get is:DODA bar
%
Upvotes: 3