From: "David A. Black" Date: 2008-08-31T03:21:39+09:00 Subject: Re: Show elements of array separated Hi -- On Sat, 30 Aug 2008, Michael Morin wrote: > Robert Klemme wrote: >> irb(main):010:0> foo.inject {|a,b| "#{a}, #{b}"} >> => "a, b, c" >> irb(main):011:0> ["a"].inject {|a,b| "#{a}, #{b}"} >> => "a" >> irb(main):012:0> [].inject {|a,b| "#{a}, #{b}"} >> => nil >> irb(main):013:0> >> >> But note the empty Array case. >> >> Kind regards >> >> robert > > irb(main):006:0> [].inject{|a,b| "#{a}, #{b}" } or "" > => "" Or: [].inject {...}.to_s In any case I think this is a job for #join :-) David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!