From: Sam Roberts Date: 2005-05-24T08:34:32+09:00 Subject: Re: [ ruby-Patches-1939 ] Pathname, totally revamped Quoting Daniel.Berger@qwest.com, on Mon, May 23, 2005 at 11:06:58PM +0900: > > If Pathname inherits String, Pathname is-a String. > > So some people (in some context) that Pathname.new("a") + > > Pathname.new("b") results in "ab" as String. > > I have explicitly decreed that the behavior of '+' is different. It's > documented - people will just have to accept it. Otherwise, we should But I don't even know, and can't... Pathname IS a String, so someone will/should pass it into methods of a class in my libraries that expects a String. When I want a String, I make sure it has #to_str, the duck-type way. Then I use it's +, and it does the wrong thing. If it doesn't behave like a String, then it is not a string. (if it doesn't waddle like a duck, its not a duck) Sometimes called Liskov substitution principle. > never override any method in a subclass, because hey, people might not > expect different behavior. You derive to override implementation, not behaviour. Cheers, Sam