Friday, 13 July 2018

Trying to use "eval(str)" on the left side of an equation to address a variable. How can I do this?

hey guys!I'm attempting to address a variable that is specified in an argument through a string.I know that if I have a string called variable_name, I can access that variable like this:var foo = eval(variable_name);but I am trying to store a value to a variable addressed by a variable name. For example:var foo = 0;string variable_name = "foo";eval(variable_name) = 10; //<-this does not work!How do I do this?

Submitted July 13, 2018 at 05:56PM by thenewstampede

No comments:

Post a Comment