Home > Enterprise >  Rules for combining pipe and parentheses in Ruby
Rules for combining pipe and parentheses in Ruby

Time:04-04

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?

CodePudding user response:

As others mentioned, this is called "array destructuring" or array decomposition. See: https://docs.ruby-lang.org/en/2.1.0/syntax/assignment_rdoc.html#label-Array Decomposition .

  • Related