I can’t even count how many times I’ve seen code like this:
Ruby can automatically split arrays in iterators by simply giving more than 1 parameter to a block:
It works with any interator method, not just each:
In fact ruby even allows you to nest splitting:
This is especially useful with Array#zip
method: