- Home /
For in a hash table
I was wondering if it's possible to do a for loop with a hash table. I know how to do it in python but I'm new to Javascript and don't really know how to do it for unity.
python:
for item in hashtable:
print hashtable[item]
The item returns the key and the print will return the value. What would be the equivalent in Javascript?
Answer by Eric5h5 · Mar 26, 2010 at 09:16 PM
for (var item : DictionaryEntry in hashtable)
print (item.Value);
Thank you! For anybody else that needs this, replacing the item.Value to item.$$anonymous$$ey will print the key.
It works fine in Unity 3, actually. If you don't want a warning, use #pragma downcast. Though it would be better to use a Dictionary ins$$anonymous$$d of a Hashtable anyway (for the same reasons that it's better to use List ins$$anonymous$$d of ArrayList).
Your answer
Follow this Question
Related Questions
Converting String to Variable Name 3 Answers
Boo.Lang.Hash bug? 0 Answers
Hashtable Bejeweled movement 1 Answer
Fast nearest neighbour searches 0 Answers
Hashtable problem c# 1 Answer