Iterating through a DynaDictionary

For questions and postings not covered by the other forums
M45HY
Posts: 63
Joined: Wed Jul 11, 2012 7:32 am
Location: Mansfield, Nottinghamshire, UK

Iterating through a DynaDictionary

Postby M45HY » Wed May 08, 2013 6:35 am

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
"If you can't explain it simply, you don't understand it well enough." - Albert Einstein

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: Iterating through a DynaDictionary

Postby murray » Wed May 08, 2013 8:30 am

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.
Murray (N.Z.)

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: Iterating through a DynaDictionary

Postby BeeJay » Wed May 08, 2013 4:44 pm

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.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 36 guests

cron