Issue #13025 has been reported by John Carney.

----------------------------------------
Bug #13025: String equality operator does not perform implicit conversion
https://bugs.ruby-lang.org/issues/13025

* Author: John Carney
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.3
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
According to the documentation, String#== should perform implicit conversion of non-strings, but this is not happening.

~~~
class SomeClass
  def initialize(value)
    @value = value
  end

  def to_str
    @value.to_s
  end
end

"text" == SomeClass.new("text")
# => false (expected true)
~~~

Other operators work as expected:

~~~
"text" + SomeClass.new("text")
# => "texttext"

"text" <=> SomeClass.new("text")
# => 0
~~~



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>