[ruby-core:71063] [Ruby trunk - Bug #7768] Inherited Array class missing

From: blazeeboy@...
Date: 2015-10-12 13:32:45 UTC
List: ruby-core #71063
Issue #7768 has been updated by Emad Elsaid.


Charlie Somerville wrote:
> =begin
> Looks like a regression introduced in r26987
> =end

This Bug stil exists in my current ruby version 
> ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]

and had to make this workaround in my custom class 

> class Custom < Array
>  def uniq
>   return self if empty?
>   super
>  end
> end

----------------------------------------
Bug #7768: Inherited Array class missing
https://bugs.ruby-lang.org/issues/7768#change-54431

* Author: Roman Ivanilov
* Status: Assigned
* Priority: Normal
* Assignee: Charlie Somerville
* ruby -v: 1.9
* Backport: 
----------------------------------------
=begin
Hello. I apologize if I missed something.
I found strange behavior in ruby 1.9:

 class Custom < Array; end
 Custom.new(0){|i| i + 1}.uniq.class # => Array
 Custom.new(2){|i| i + 1}.uniq.class # => Custom

while in 1.8 it works just as I expected. 

 class Custom < Array; end
 Custom.new(0){|i| i + 1}.uniq.class # => Custom
 Custom.new(2){|i| i + 1}.uniq.class # => Custom

* it is actual not only for the uniq method.
* tested with ree-1.8.7-2010.02, ruby-1.9.2-p290, ruby-1.9.3-p375, ruby-1.9.3-p125

Any bug here?

=end



-- 
https://bugs.ruby-lang.org/

In This Thread