Actions
Bug #14374
closed`for` does not splat elements
Bug #14374:
`for` does not splat elements
Description
In general, it is said that for
statement and each
method call are similar, except for the scope of loop variables.
I found another difference, since 1.9.
a = [Struct.new(:to_ary).new([1, 2])]
a.each {|i, j| p [i, j]} #=> [1, 2]
for i, j in a; p [i, j]; end #=> [#<struct to_ary=[1, 2]>, nil]
In 1.8, the latter result equals the former.
Is this intentional?
Actions