Bug #4136: Enumerable#reject should not inherit the receiver's instance variables
http://redmine.ruby-lang.org/issues/show/4136

Author: Hiro Asari
Status: Open, Priority: Normal
ruby -v: ruby 1.9.3dev (2010-11-28 trunk 29965) [x86_64-darwin10.5.0]

re
Below, you see that a.reject returns a copy of the receiver, which inherits the instance variable @foo. This is not the case with Array#select.

irb(main):001:0> a=[]
=> []
irb(main):002:0> a.instance_variable_set "@foo", "bar"
=> "bar"
irb(main):003:0> a.reject {}.instance_variable_get "@foo"
=> "bar"
irb(main):004:0> a.select {}.instance_variable_get "@foo"
=> nil


1.8.x behaves the same way.


----------------------------------------
http://redmine.ruby-lang.org