1

Given the array

["zone", "abigail", "theta", "form", "libe", "zas"]

Is there a straightforward way to go through the array and combine the strings into pairs, thus...

["zoneabigail", "abigailtheta", "thetaform", "formlibe", "libezas"]
0

1 Answer 1

7

You are searching for Enumerable#each_cons:

words.each_cons(2).map(&:join)
Sign up to request clarification or add additional context in comments.

2 Comments

This is really good - works well. I apologise for not giving my attempts. My issue is that I didn't know where to start. This gives me something to study.
@GhostRider happy to help.

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.