Sorry for the title, I don't know how this syntax is called.
For example:
ary = [ [11, [1]], [22, [2, 2]], [33, [3, 3, 3]] ]
Ruby 1.8
ary.map{|x, (y,)| [x, y] } #=> [[11, 1], [22, 2], [33, 3]] ary.map{|x, (y)| [x, y] } #Syntax error, unexpected '|', expecting tCOLON2 or '[' or '.' #ary.map{|x, (y)| [x, y] } # ^
Ruby 1.9
ary.map{|x, (y,)| [x, y] } #SyntaxError: (irb):95: syntax error, unexpected ')' #ary.map{|x, (y,)| [x, y] } # ^ ary.map{|x, (y)| [x, y] } #=> [[11, 1], [22, 2], [33, 3]]
※ I am not asking for a way to get the desired array.
I would like to know why this piece of code works, or is one of the Ruby versions, but not two .