From: "Chr. Rippel" Date: 2002-01-28T00:34:14+09:00 Subject: Re: Subrange of String subclass => invalid object "Tobias Reif" wrote in, .... There are two ways of resolving this inconsistency - I would prefer if these operation would always return a String since this is an accordance with the general behavior - i.e. if you want #upcase return a Foo it should be your responsiblity to override it (a simple #dup.upcase!) Thinking about it - if the implementation of #upcase is changed to ---- class String def upcase dup.upcase! end end # then the subclassing behavior becomes logical and works # as expected class HistoryString < String def initialize (str) super @orig_length = length end def dup (res = super).orig_length = length res end alias clone dup attr_accessor :orig_length end qwert2 = (HistoryString.new 'qwert').concat 'qwert' qwert2.concat p qwert2.orig_length # => 5 p qwert2.upcase.orig_length # => 10 ---- I guess this would be fine with me - in general I am not a fan of type-magic. /Christoph