Wadstk
Wadstk

Reputation: 185

Ruby Array into string with brackets

I have an array like so: ["data","data2"]

What would be the most Ruby-like way to convert this into a string with brackets included: "['data','data2']"

Thanks

Upvotes: 2

Views: 3262

Answers (1)

bta
bta

Reputation: 45057

I can't say how "ruby-ish" this is, but it's what I would typically do:

puts "['" + array_of_strings.join("','") + "']"

Upvotes: 5

Related Questions