I have a question about foreach in tcl:
foreach id "6 8" {
#do something here;
}
is this "6 8" a list? and what does “6 8” mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The main thing to remember is that Tcl doesn’t have types, per se, at least not in a way that the user should need to worry about them. Rather, each value is a string and each command tries to treat it as the type of value it needs.
For example:
For your code, the value
6 8is being interpreted as a list by theforeachcommand, with the value6and8. The double quotes around the value just group the content inside them as a single value. They (the dqs) don’t signify any specific type (ie, string, list, number).