I`m not really sure when I should use a dictionary in my applications.
Everytime I code a switch case that returns a single value, for example, should I strive for a dic?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A dictionary is useful whenever you have a natural key->value relationship.
This is the case in a language dictionary (key:one word value:List of translations), or for a document index (key:title, value:text body).
If you find yourself coding a switch statement where each case is only responsible for returning a single value you have such a natural key->value relationship and should use a dictionary.