Weblog

RSS

Enumerable#partition

Today as I was working on a simple feature on a project I asked Github Copilot to review a piece of code and got back the following feedback:

The collection is iterated twice unnecessarily. Consider using `partition` to split it in a single pass, e.g.:
(1..6).partition { |v| v.even? }
=> [[2, 4, 6], [1, 3, 5]]

I gotta thank Copilot. This is a very nice method to know about.

Hello World

This is the initial post of this blog.

The question is: will there be more?