Re:Try Ruby (in your browser, now with 1.9)
by harpastum on Thursday January 07, 2010 @09:19PM
(#1038609)
Wouldn't it make more sense to use each rather than map for that example?
Map is for creating a new array with each of the results in it, like this:
which would return an array with each of the strings in it.
[ Parent
| on HN ]
Re:Try Ruby (in your browser, now with 1.9)
by jamesbritt on Thursday January 07, 2010 @10:21PM
(#1038744)
Quite right.
puts %w{apple pear banana}.map {|f| "#{f} is a fruit."}.join(' And ')