M Kumar M Kumar - 3 months ago 10
Ruby Question

Ruby array to string conversion

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

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

Comments