Getting the keys for an associative array
Is there a way to get all the keys that are used as indices into an associative array? I was wondering if this is something that is in the works, or is it already available? I was thinking something like... ************* Object myAssociativeArray[0]; new Object @=> myAssociativeArray["first"]; new Object @=> myAssociativeArray["second"]; myAssociativeArray.keys => string keysList[]; for(0 => int i; i < keysList.cap(); i++) { <<< () => myAssociativeArray[keysList[i]].printObject >>>; } ************* Also, would there be a way of ensuring some sort of order inwhich the keys are returned (ie, the order inwhich they were added to the array???)? Mike
Hi Mike! You are totally right. We don't any way to iterate through the contents of the associative side of arrays. We will put that on the TODO list for 1.2.0.6. 1.2.0.5 is very late (compared to earlier estimates), but will also have many more features than we thought. We are hoping to get this out later this week. Stay tuned. Plans for 1.2.0.6 have already been solidified, more on that later. Best, Ge!
Is there a way to get all the keys that are used as indices into an associative array? I was wondering if this is something that is in the works, or is it already available? I was thinking something like...
*************
Object myAssociativeArray[0];
new Object @=> myAssociativeArray["first"]; new Object @=> myAssociativeArray["second"];
myAssociativeArray.keys => string keysList[];
for(0 => int i; i < keysList.cap(); i++) { <<< () => myAssociativeArray[keysList[i]].printObject >>>; }
*************
Also, would there be a way of ensuring some sort of order inwhich the keys are returned (ie, the order inwhich they were added to the array???)?
Mike _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (2)
-
Ge Wang
-
Mike McGonagle