Ruby array to string conversion

Sachin R picture Sachin R · Aug 17, 2010 · Viewed 275k times · Source

I have a ruby array like ['12','34','35','231'].

I want to convert it to a string like '12','34','35','231'.

How can I do that?

Answer

corroded picture corroded · Aug 17, 2010

I'll join the fun with:

['12','34','35','231'].join(', ')

EDIT:

"'#{['12','34','35','231'].join("', '")}'"

Some string interpolation to add the first and last single quote :P