开发者

How to replace/reset an element value in a TCL array?

开发者 https://www.devze.com 2023-02-23 00:04 出处:网络
Say I have an array开发者_开发技巧 in a TCL, and I want to change the value of the element which has a key say \"First_elem\". How I can do this?Just set the array element like any other variable: set

Say I have an array开发者_开发技巧 in a TCL, and I want to change the value of the element which has a key say "First_elem". How I can do this?


Just set the array element like any other variable: set myArray(key) "value"

Here's a more complete example:

array set myArray {
    key1 1234
    key2 5678
}

echo $myArray(key1)
set myArray(key1) "test"   // Change an existing element
set myArray(key3) "hello"  // Add a new element
echo $myArray(key1)
0

精彩评论

暂无评论...
验证码 换一张
取 消