From: Navindra Umanee Date: 2005-03-14T04:10:33+09:00 Subject: Re: how do you duck-type something to String, so String believes you? Sam Roberts wrote: > I can give something a #to_str, which should be an indication that it is > duck-type compat to a String (as opposed to #to_s, which converts > something to a String). String is also strongly-typed in C as T_STRING, so Ruby duck-typing is not going to save you here. Ruby is riddled with that sort of thing, probably for efficiency and implementation reasons. What you can do is override String.== to take this into consideration. class String alias :_equals :== def ==(o) _equals(o.to_s) end end Cheers, Navin.