Computer Science Canada Variable name from a string |
Author: | maxudaskin [ Sun Jun 08, 2008 1:09 pm ] | ||
Post subject: | Variable name from a string | ||
Is it possible to check a variable using it's name as a string?
Max ![]() |
Author: | Tony [ Sun Jun 08, 2008 1:31 pm ] | ||
Post subject: | RE:Variable name from a string | ||
yes, if that variable is a Hash / HashMap. Which is an Array with a string used for an index. Arrays should be sufficient for your game.
More on arrays, in the Turing Walkthrough |
Author: | maxudaskin [ Sun Jun 08, 2008 4:01 pm ] | ||
Post subject: | Re: Variable name from a string | ||
Do you mean
or is what you wrote correct? |
Author: | Tony [ Sun Jun 08, 2008 4:17 pm ] |
Post subject: | RE:Variable name from a string |
... you are right, I meant player_squares(current_row,current_column) I don't actually code in Turing, or even have it available. |
Author: | maxudaskin [ Sun Jun 08, 2008 5:07 pm ] |
Post subject: | Re: RE:Variable name from a string |
Tony @ Sun Jun 08, 2008 4:17 pm wrote: ... you are right, I meant player_squares(current_row,current_column)
I don't actually code in Turing, or even have it available. Java? |
Author: | syntax_error [ Sun Jun 08, 2008 5:18 pm ] |
Post subject: | RE:Variable name from a string |
no as far am I am aware he is a ruby admirer, nonetheless the code was just of syntactically, not a huge mistake, you did get the idea of what you should be doing no? |
Author: | Tony [ Sun Jun 08, 2008 5:21 pm ] |
Post subject: | RE:Variable name from a string |
I don't like Java, because Java sucks. |