Issue #7522 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee changed from mame (Yusuke Endoh) to matz (Yukihiro Matsumoto)
Target version changed from 2.0.0 to next minor

Sorry but let me postpone this to the next minor.
I'm afraid if the existing code depends on the traditional behavior.
It should have been included in rc1, which is my fault.  Sorry, blame me.

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Bug #7522: Non-core "Type()" Kernel methods return new objects
https://bugs.ruby-lang.org/issues/7522#change-35773

Author: jballanc (Joshua Ballanco)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor
ruby -v: 2.0.0-preview1


The methods Array(), String(), Float(), Integer(), Hash(), and Rational() all return their argument when the argument is already an instance of the type in question. For example:

a = []
a.equal? Array(a) #=> true

However, the similar methods Pathname(), BigDecimal(), and Complex() do not do this:

p = Pathname.new('/tmp')
p.equal? Pathname(p) #=> false

I had the impression that the "Type()" methods were intended as "safe" coercion methods. That is, if no type conversion is required, then the system is left unchanged (and no new objects are created). The attached patch fixes the three methods mentioned above to adhere to this same invariant.


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