Converting ruby array to array of consecutive pairs

Viewed 20245

What is the easiest way to convert a ruby array to an array of consecutive pairs of its elements?

I mean:

x = [:a, :b, :c, :d]

Expected result:

y #=> [[:a, :b], [:c, :d]]
2 Answers
Related