From: George Ogata Date: 2004-09-09T17:45:05+09:00 Subject: Re: ruby-dev summary 24171-24235 Ben Giddings writes: > I like Kristof Bastiaensen's idea of pattern matching >> [[1, 3], [2, 9], [3, 27]].each do |[arg1, arg2]| >> p arg1.inspect #=> 1 >> p arg2.inspect #=> 2 >> end > > But I'm not sure how radical a change that would be to the language, or > how easy it would be to do. If all you want is pattern matching when receiving Arrays, it's already there -- just use parens instead of brackets: irb(main):001:0> [[[1, 2], 3], [[4, 5], 6]].each do |((a, b), c)| irb(main):002:1* p a irb(main):003:1> p b irb(main):004:1> p c irb(main):005:1> end 1 2 3 4 5 6 => [[[1, 2], 3], [[4, 5], 6]]