I’m just trying to get a grip on when you would need to use a hash and when it might be better to use an array. What kind of real-world object would a hash represent, say, in the case of strings?
Share
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.
I believe sometimes a hash is referred to as a ‘dictionary’, and I think that’s a good example in itself. If you want to look up the definition of a word, it’s nice to just do something like:
Instead of trying to figure out the correct numeric index that the definition would be stored at.
This answer assumes that by ‘hash’ you’re basically just referring to an associative array.