Reputation: 2170
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"]
Upvotes: 1
Views: 124
Reputation: 36110
You are searching for Enumerable#each_cons
:
words.each_cons(2).map(&:join)
Upvotes: 7