Given
a = [[:a, :b, :c]]
1) I understand this
a.each{|(x, y), z| p z} # => :b
that there are two variables (x, y)
and z
, so the third element :c
is thrown away, and z
matches :b
. And I understand this
a.each{|(x, y), z| p y} # => nil
that (x, y)
matches :a
, and since it is not an array, there are no elements to it, and so y
matches nil
.
But how does
a.each{|(x, y), z| p x} # => :a
work? I expect nil
to be returned.
2) Why are the return values like this?
a.each{|(x, y)| p x} #=> :a
a.each{|(x, y)| p y} #=> :b
I expect them to both return nil
.