From: "C. Dagnon" Date: 2009-03-05T06:32:31+09:00 Subject: Re: Any solutions to Ruby's inconsistencies? Yossef Mendelssohn wrote: > There's been endless discussion and confusion about Symbols, Strings, > what they mean, what they should be used for, and their relation to > each other. Rails did not help with HashWithIndifferentAccess, though > I imagine they thought they would. But I don't want to start anything I'm happy I didn't miss anything and sad to hear I'm not alone in that confusion. > like that up. I just want to point out that a lot of that code is > unnecessary and could just be: > > key = map.keys.detect { |k| k.to_s.downcase == > matcher.to_s.downcase } Hmmm, what is 'detect'? I had been doing that, but then I thought that compiling a single regex would be less expensive than downcasing everything every time they got compared. Not that the example I included appears in any of my code, but I've been doing it for similar situations to allow for things like case-indifferent parameters. >> 4. And what's up with Ruby incorrectly naming their Map 'Hash'? > ... > At least they're not called "dictionaries", right? Am I right? Yes, definitely right on that one. Okay, so that was a Perl influence. Darn. > ... > Hey, why aren't Arrays called Maps instead? Sure arrays can be considered special kinds of maps. The ordering problem could be solved by my_map.keys.sort.each instead of my_array.each. The major difference I see is that Arrays have type-checked and validated keys (non-negative integers), though I would also say there's an assumption in how I've gotten used to using arrays that if there is an element 5, there are elements 0-4 (even if nil). Thanks for the reply! -Chris -- Posted via http://www.ruby-forum.com/.