From: Martin Weber Date: 2001-11-20T21:08:52+09:00 Subject: [ruby-talk:25908] Re: String#== : Why not error with different type? On Tue, Nov 20, 2001 at 08:51:53PM +0900, Ryo Furue wrote: > I think it would be nice if String#== raised error if the argument > isn't a String. What was the reason why the designer(s) of the String > class decided the equality method should return false as > > a = "2" > b = 2 > a == b # => false > > ? I wish the last line raised an error.... Imho it should only raise an error if there is no method for arg2 which does #to_s. Imho a==b should be a==b.to_s implicitely, raise an error if b has no to_s method, and otherwise use the returned value of to_s to do the comparison. Thus in your example, a="2" b=2 a==b # -> should be true if b has #to_s Martin Weber