0

So, I have array:

 set b(1,2,3,4) 5

and I can get its element using

   array get b {1,2,3,4}

#but I can't find the way to pass that key list argument # as a previously defined variable

set x { 1 2 3 4}
array get b x  #does not work
array get b $x #does not work

How to do it?

1
  • Don't use array get to fetch single values out of arrays; it is a command that fetches many values in one operation, and is therefore relatively expensive. Commented Dec 24, 2016 at 1:18

1 Answer 1

1

The value { 1 2 3 4} is not equal to 1,2,3,4.

% set x 1,2,3,4
1,2,3,4
% array get b $x
1,2,3,4 5
% set b($x)
5

Documentation: array

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.