Umesh Kumar Umesh Kumar - 4 months ago 50
Ruby Question

Remove brackets around an array in ruby

Lets say I have an array

array = ["Hii", "Hello", "Bye"]


I want to show the array in following format

"Hii","Hello","Bye"


What would be the best way to do it?

Answer
▶ a = ["Hii","Hello","Bye"]
#⇒ ["Hii", "Hello", "Bye"]
▶ puts a.inspect[1...-1]
#⇒ "Hii", "Hello", "Bye"
Comments