'Rules for combining pipe and parentheses in Ruby

In ruby you can do things like:

[[:a, [:z, 1]]].map{|one, (two, three)| three}
=> 1

What are limits and general rules in combining pipe sections with parentheses?



Solution 1:[1]

As others mentioned, this is called "array destructuring" or array decomposition. See: https://ruby-doc.org/core-3.1.2/doc/syntax/assignment_rdoc.html#label-Array+Decomposition .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1