P
Peng Zuo
[Note: parts of this message were removed to make it a legal post.]
Hi,I'm using ruby 1.87. this problem seems to be the block context bug for
1.8x, in the results array, I always got the same value, which is the last
return value of the iteration .
I've got an object, which has multiple states. when I call each_state, I'm
actually changing the state.
results = []
an_object.each_state do |the_object|
#some manipulations
results << the_object
end
the each_state method looks like:
def each_state
#blah blah, change the current state
yield(self) # I also tried self.dup, but it didnt work either.
end
anyone knows how to solve this?
TIA
Regards,
Peng Zuo
Hi,I'm using ruby 1.87. this problem seems to be the block context bug for
1.8x, in the results array, I always got the same value, which is the last
return value of the iteration .
I've got an object, which has multiple states. when I call each_state, I'm
actually changing the state.
results = []
an_object.each_state do |the_object|
#some manipulations
results << the_object
end
the each_state method looks like:
def each_state
#blah blah, change the current state
yield(self) # I also tried self.dup, but it didnt work either.
end
anyone knows how to solve this?
TIA
Regards,
Peng Zuo