Reputation: 1082
I have an array
arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]]
and i want to convert
arr=["Sumit where", "where are", "are you"]
how can i do this in efficient way
Upvotes: 0
Views: 75
Reputation: 6394
arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]]
v = arr.map { |x| x.join(" ") }
p v
Upvotes: 2
Reputation: 8169
try:
arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]]
arr = arr.map {|i| i.join(' ') }
Upvotes: 0