Array to string

If I have a array: a = [ "a", "a", "b", "b", "c" ]

How can I get a string: "a, a, b, b, c"

···

--
Posted via http://www.ruby-forum.com/.

Fresh Mix schrieb:

If I have a array: a = [ "a", "a", "b", "b", "c" ]

How can I get a string: "a, a, b, b, c"

[ "a", "a", "b", "b", "c" ].join(', ')

If I have a array: a = [ "a", "a", "b", "b", "c" ]

How can I get a string: "a, a, b, b, c"

By using Array#join
  >>> irb
  >> a = [ "a", "a", "b", "b", "c" ]
  => ["a", "a", "b", "b", "c"]
  >> a.join(", ")
  => "a, a, b, b, c"

···

On [Thu, 05.03.2009 04:56], Fresh Mix wrote:

--
Dominik Honnef
dominikho@gmx.net