0

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

2 Answers 2

2
arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]]  
v = arr.map { |x| x.join(" ") }  
p v 
Sign up to request clarification or add additional context in comments.

Comments

0

try:

arr=[["Sumit", "where"], ["where", "are"], ["are", "you"]]
arr = arr.map {|i| i.join(' ') }

2 Comments

it gives ["Sumit", "where", "where", "are", "are", "you"] but i want to arr=["Sumit where", "where are", "are you]
is it possible without loop?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.