J
Jamis Buck
I stumbled on this, almost by accident, and I'm curious as to whether
this is a "feature" or a "bug".
S = Struct.new( "S", :a )
s = S.new
[ 1, 2, 3, 4, 5, 6 ].each { |s.a| puts s.a }
This prints each element of the array, but what I'm curous about, is
that the block actually assigns each value to s.a.
I like this.
However, I don't want to use this if it is liable to change. Is this
simply a side-effect of the way block parameters are being handled right
now? In other words, is this something that may potentially change in
Ruby2?
this is a "feature" or a "bug".
S = Struct.new( "S", :a )
s = S.new
[ 1, 2, 3, 4, 5, 6 ].each { |s.a| puts s.a }
This prints each element of the array, but what I'm curous about, is
that the block actually assigns each value to s.a.
I like this.
However, I don't want to use this if it is liable to change. Is this
simply a side-effect of the way block parameters are being handled right
now? In other words, is this something that may potentially change in
Ruby2?