Vladimir,

My initial inclination is to agree with you, but I
would expect the overriding factor is that this
behaviour should be consistent with that of other
classes.

Graeme

---- Original Message ----

From: "Vladimir Sizikov" <vsizikov / gmail.com>
To: ruby-core / ruby-lang.org
Cc: 
Subject: [ruby-core:17918] String methods on
subclasses return "uninitialized" objects
Date: Wed, July 23, 2008, 06:22:00

Hi,

During the work on RubySpec tests, we had an
interesting discussion on
String methods behavior which we'd like to
double-check with
ruby-core.

Say, we have a subclass of String, and then invoke
#split on that
subclass instance. That method will return
instances of that subclass
as well, as expected, but it seems that the
#initialize method in not
really invoked at all. Is that intentional or
accidental?

It seems to me that if there is a custom
initialize method written for
that subclass, it is there for a reason (maybe,
all objects require
some customization), but in case of many String
methods, the created
instances are not properly initialized. Opinions?

Thanks,
  --Vladimir