Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add Enumerable#each_cons_pair and Iterator#cons_pair yielding a tuple #8332
# new: [1, 2, 3, 4, 5].each_cons do |a, b| puts a * b end # old: [1, 2, 3, 4, 5].each_cons(2, reuse: true) do |pair| a, b = pair puts a * b end
It's a convenience feature that also improves performance.
I've added the same behaviour to