Page 1 of 1

Iterating through a DynaDictionary

Posted: Wed May 08, 2013 6:35 am
by M45HY
Hi Guys,

Just had a quick question on whether someone knows how I could iterate through a DynaDictionary to find a certain data record and then update the value within that DynaDictionary data record? I was wondering whether I should use an iterator or a foreach loop? For example, if I have a DynaDictionary that stores a string value (i.e. a person's name) and an integer (i.e. their age), how can I iterate through the DynaDictionary for a certain name (i.e. John Smith) just so that I can update their age (i.e. from 22 to 23)?

Thanks,
Omash

Re: Iterating through a DynaDictionary

Posted: Wed May 08, 2013 8:30 am
by murray
You can use an Iterator or a foreach loop, as appropriate, just as you would for other Jade collection types such as MemberKeyDictionary and ExtKeyDictionary.
The behaviour is common, except that the dictionary's membership and keys are defined at runtime. e.g. you can also perform single lookups via getAtKey(), etc, etc.

Re: Iterating through a DynaDictionary

Posted: Wed May 08, 2013 4:44 pm
by BeeJay
Hi Guys,

Just had a quick question on whether someone knows how I could iterate through a DynaDictionary to find a certain data record and then update the value within that DynaDictionary data record? I was wondering whether I should use an iterator or a foreach loop? For example, if I have a DynaDictionary that stores a string value (i.e. a person's name) and an integer (i.e. their age), how can I iterate through the DynaDictionary for a certain name (i.e. John Smith) just so that I can update their age (i.e. from 22 to 23)?

Thanks,
Omash
I guess I'll bite.... What is the use-case for having a dictionary keyed by both name and age?

Cheers,
BeeJay.