How to put a variable into a variable name: eval();

var id : int = 1;
var item1 : String = "ho";
var item2 : String = "hum";

print(eval("item" + id));
This can of course be used for a lot more than just variables…
I’m guessing that this won’t work on the iPhone due to the ahead of time compiling, but I haven’t actually tried…
Bookmark the permalink. Follow any comments here with the RSS feed for this post. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>