News for hackers. Stuff that matters.
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?

    %w{apple pear banana}.each {|f| puts "#{f} is a fruit."}
    => apple is a fruit
    => pear is a fruit
    => banana is a fruit
Map is for creating a new array with each of the results in it, like this:

    %w{apple pear banana}.map {|f| "#{f} is a fruit."}
    =>["apple is a fruit.", "pear is a fruit.", "banana is a fruit."]
which would return an array with each of the strings in it.
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 ')