Dinesh
Dinesh

Reputation: 16438

Using {*} in Tcl

I am reading the book Tcl/Tk, Third Edition: A Developer's Guide and found the following piece of code in page number 42.

# This works
set nameANDvalue "a 2"
set { ∗ }$nameANDvalue
puts $a

I tried to run the same in tcl shell and got the following error

% set nameANDvalue "a 2"
    set { * }$nameANDvalue
    puts $a
a 2
% extra characters after close-brace
% can't read "a": no such variable
% 

What is my mistake here ?

Upvotes: 1

Views: 89

Answers (1)

Captain
Captain

Reputation: 2228

there shouldn't be spaces within the braces:

set {*}$nameANDvalue

FYI - when you have the spaces, it is taking * (with space before and after) as the variable name... so you could, for example, set { * } fubar

Upvotes: 2

Related Questions