From: David Masover Date: 2010-02-07T04:40:42+09:00 Subject: Re: Hashes versus Arrays People may be over-complicating things a bit. On Wednesday 03 February 2010 12:27:10 pm Jerome David Sallinger wrote: > Can someone please explain how you would go about deciding whether to > use a Hash or and Array for a given requirement. Is it just a list of values, ordered or not? Put it in an Array. Example: friends_list = ['Tom', 'Susie', 'Yosef'] A hash is an associative array, not necessarily sorted. Do you have things you need to associate? people_list = {'Tom' => :friend, 'Joe' => :enemy} people_list['Tom'] # should return :friend people_list['Joe'] = :friend #guess we made up These are entirely different patterns. You almost never have a requirement that would make sense for either. People are complicating this by the fact that arrays can be indexed by position. For example: friends_list[1] # who's my second friend? But in high-level languages like Ruby, especially when you're starting out, you probably don't need to be doing that. > Can someone give an > idiot proof simple explanation No. You're a programmer. If you're also an idiot, you end up on thedailywtf. "Idiot-proof programming" is neither.