Could you please explain me why String instance methods return subclass,
and MyStr#to_s returns String, not the receiver as specified?
String (and Array) methods that return new strings (arrays) tend to
return instances of the receiver's class rather than String. This
often makes subclassing a bit less painful, although a couple of pies
have been flung over it too:
Thanks for references,
I understand that it was discussed already, and decision was made;
imho: it's irregular and not OO, but who cares about formal, theoretical
correctness, 'be practical' criteria rules!
Regarding 'to_s, to_str returning String': hope documentation will be fixed;
regards
Sergey
"George Ogata" <g_ogata@optushome.com.au> wrote in message
news:87ek182n78.fsf@optushome.com.au...
···
"S.Volkov" <svolkov@comcast.net> writes:
Could you please explain me why String instance methods return subclass,
and MyStr#to_s returns String, not the receiver as specified?
String (and Array) methods that return new strings (arrays) tend to
return instances of the receiver's class rather than String. This
often makes subclassing a bit less painful, although a couple of pies
have been flung over it too: