|
-
Multidimensinal array toString?
I have a Multidimensinal array 'moods'.
red = ["fire","warm"];
blue = ["water","cold"];
black = ["night",dark"];
moods = [red,blue,black];
how do I get the seperate names in moods?
( a function that returns the literal "red" when i ask for *something* moods[0])
regards
Podenphant
-
var temp=moods[0][1] -- will return fire
hope thats waht your after
-
sorry it will of course return warm!
-
half as fun, double the price
moods doesnt know red blue or black. As soon as you create moods and include those arrays, moods stores a reference to the arrays given and not the variable name itself. Just as the variable red points to the place of ["fire","warm"] in memory, so then does moods[0], bypassing the variable red all together.
What you could do is include the actually color in with the string arrays
red = ["red","fire","warm"]
or try something weird like
red = ["fire","warm"];
blue = ["water","cold"];
black = ["night",dark"];
moods = ["red","blue","black"];
moods[0] // "red"
this[moods[0]][0] // "fire"
-
thanks senocular, leaves me with ½ an hour of copy->paste
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|