0
$\begingroup$

This question already has an answer here:

How can I assign a value for a symbol composed of a string plus and another string converted from integer?

n=3;
Symbol["as"<>ToString[n]]=4;

So I want to assign a value 4 to the new symbol as3. But it does not work.

$\endgroup$

marked as duplicate by Kuba Oct 11 '17 at 21:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Evaluate@Symbol["as" <> ToString[n]] = 4. It will only work once. $\endgroup$ – march Oct 11 '17 at 21:33
  • $\begingroup$ Linked topic should answer your question, let me know if you disagree with closing. $\endgroup$ – Kuba Oct 11 '17 at 21:36
1
$\begingroup$

Is this what you want?

n = 3;
Set[#, 4]& @ Symbol["as" <> ToString[n]]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.