Project

General

Profile

Feature #13025

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

According to the documentation, String#== should perform implicit conversion of non-strings, but this is not happening. 

 ~~~ruby ~~~ 
 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: 

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

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

Back