Project

General

Profile

Bug #4136

Enumerable#reject should not inherit the receiver's instance variables

Added by hasari (Hiro Asari) over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-11-28 trunk 29965) [x86_64-darwin10.5.0]
Backport:
[ruby-core:33640]

Description

=begin
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.
=end


Related issues

Related to Ruby master - Bug #7625: Arrayを継承したオブジェクトのcompactがArrayを返すClosedmatz (Yukihiro Matsumoto)12/26/2012Actions
Related to Ruby master - Bug #7768: Inherited Array class missingClosedmatz (Yukihiro Matsumoto)Actions

Also available in: Atom PDF