Ruby array to string conversion Ruby array to string conversion ruby ruby

Ruby array to string conversion


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


> a = ['12','34','35','231']> a.map { |i| "'" + i.to_s + "'" }.join(",")=> "'12','34','35','231'"


try this code ['12','34','35','231']*","

will give you result "12,34,35,231"

I hope this is the result you, let me know


matomo