Split nested block parameters

If you iterate over a collection of arrays, you can destructure the arrays within the block parameters:

movies_and_directors = [
  ['The Big Lebowski', 'Coen Brothers'],
  ['Fight Club', 'David Fincher']
]
movies_and_directors.each do |movie, director|
  # do something
end

For nested array (e.g. when you use each_with_index), you can use parentheses for destructuring:

movies_and_directors.each_with_index do |(movie, director), index|
  # do something
end
Tobias Kraze