Sorry for the title, I don't know how this syntax is called.
For instance:
ary = [ [11, [1]], [22, [2, 2]], [33, [3, 3, 3]] ]
# want to get [ [11, 1], [22, 2], [33, 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 wanted array.
I would like to know why this piece of code is working is either one of the Ruby's version but not both.