amateur
amateur

Reputation: 951

Converting a list to an array

Consider the sample code below, i need to convert the list "nvlist" back to an array. How can i do that?

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

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

Upvotes: 4

Views: 9840

Answers (2)

TrojanName
TrojanName

Reputation: 5355

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

Upvotes: 0

RHSeeger
RHSeeger

Reputation: 16262

array get and array set are inverses:

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

Upvotes: 6

Related Questions