18 Mar '13, 10am

Well that escalated quickly #umm....

> I've been using collect in all my programs up till now, and I recently > discovered that the map function is equivalent. My question is, (and I > know that it really doesn't matter), which is more correct to use if > you're trying to stick to doing things ruby's way? What do people on > this newsgroup generally prefer using? > > Thanks in advance for you oppinions. I usually use #map if I want to collect the return values generated from calling a method with each item in the enumerable as an argument: results = arr.map { |item| process(item) } I use #collect when I want to collect attributes from each item in the enumerable: names = contacts.collect { |contact| contact.name } This is just what seems logical to me; I'm not aware of any real convention on the matter, though it may be a good idea. Cheers, Daniel

Full article: http://www.ruby-forum.com/topic/40771

Tweets

World Bike-Sharing Programs (Map)

cleantechnica.com 17 Mar '13, 3pm

Of course, there are a few other bike-sharing programs in other locations, but those three regions certainly lead the show...

Content Marketing vs. PR: What's the Difference?

Content Marketing vs. PR: What's the Difference?

wordstream.com 18 Mar '13, 12pm

I recently spoke with an analyst who had asked me how content marketing is different from traditional PR (public relations...

World not coping well with change in diets, FAO...

eco-business.com 18 Mar '13, 12am

Urbanization, economic growth and other transformations are causing changes in lifestyles and diets in many parts of the w...