From: Mark Hahn Date: 2001-11-24T04:49:44+09:00 Subject: [ruby-talk:26249] Re: String#== : Why not error with different type? .equ? does exactly what you want. It matches content and type. == content only .equ? content and type .equal? exact object -----Original Message----- From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org] Sent: Friday, November 23, 2001 6:39 AM To: ruby-talk ML Subject: [ruby-talk:26230] Re: String#== : Why not error with different type? Hi, In message "[ruby-talk:25907] String#== : Why not error with different type?" on 01/11/20, Ryo Furue writes: |I think it would be nice if String#== raised error if the argument |isn't a String. No. It makes something harder in dynamic typed languages like Ruby. For example, where ary is a non homogeneous array. ary.select{|x| x == "foo"} should be protected like ary.select{|x| begin x == "foo" rescue TypeError; false; end} It's sort of like static typing. You can use <=> for String-only comparison. "abc" <=> "abc" # 0, means same "abc" <=> 2 # error matz.