On Thursday, September 30, 2004, 11:28:07 PM, Gavin wrote: > On Sep 30, 2004, at 7:12 AM, Chris Pine wrote: >> (Yes, if you are teaching Ruby to a functional programmer, you use map >> instead of collect (are those really the same? I just always avoided >> collect: wrong english word, I think), but you still teach them only >> *one* of them.) > Funny, I never understood what #map did. People used it all the time > and it baffled me. I kept saying "I should learn this method, because > people keep showing how to use it for powerful, terse solutions, > but...I'm baffled." > Then someone showed me the #collect method, and I fell in love. It's > awesome. I extended arrays in Javascript to use it, I love it so much. > ...it was a week later than I pulled up the documentation and saw that > they're the same thing. One of the first things I learned about Ruby was that some methods are aliased. It never occured to me to dislike this, it's never caused me any problems, and I _really_ like "map" (the name and the method) and don't understand where the name "collect" comes from. But 'ri' tells me they're the same -- it's not like there's a conspiracy to hide the fact. Maybe people just need to learn about the alias thing early on, know how to look out for it, and be happy ever after :) Gavin BTW, the method "map" maps a function onto a set and returns the result. I think that's the right terminology. It comes from functional languages, anyway. In Miranda (and I presume Haskell): f(x) = x * 5 + 1 map f [10..15] # -> [51, 56, 61, 66, 71, 76]