Converting a list to an array

Consider the example code below, I need to convert the "nvlist" back to an array. How can i do this?

for {set i 0} { $i < 3} {incr i} {
    set color($i) $i    
}
set nvList [array get color]

      

After that, I have data in nvlist and I need to change that back to an array. How can i do this?

+3


source to share


2 answers


array get

and array set

are inverse:



set dict [array get myArr]
array set myArrCopy $dict

      

+5


source


Well, actually you already have an array called "color" so in theory you shouldn't need to do anything. :-)



0


source







All Articles