Array to string


#1

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

How can I get a string: “a, a, b, b, c”


#2

Fresh M. 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(’, ')


#3

On [Thu, 05.03.2009 04:56], Fresh M. wrote:

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”