Programming Question
agree at carltonfields.com
agree at carltonfields.com
Fri Apr 9 14:35:22 UTC 1999
I'm not sure that's right either. In kpgrant's example as understood, className species would always be an instance of class String, which instance containrf the <name> of the class he hoped to instantiate.
As a concrete exampe, compare:
'OrderedCollection' species new
which generates an empty String object, with
(Smalltalk at: 'OrderedCollection' asSymbol) new
which generates an empty OrderedCollection object.
-----Original Message-----
From: MIME :rlpa80 at email.sps.mot.com Sent: Friday, April 09, 1999 10:07 AM
To: kpgrant at mindspring.com
Cc: squeak at cs.uiuc.edu
Subject: Re: Programming Question
Kevin,
This is an answ3er from a newbie, but I do think it is correct.
You want to used the method "species" as shown below. I used this
technique in a fix to class Path that I posted recently.
Best Regards,
John-Reed Maffeo Mesa, Arizona
kpgrant at mindspring.com wrote:
> > Here's one I'm having trouble figuring out...
> > I have an object of class String something like the following:
> > className := 'OrderedCollection'
> > What I want to do is something like:
> > newObject := (className asClass) new
newObject := className species new
> > Of course there is no such message as "asClass". The problem
> is that I can find no way to cause newObject to become a new
> object of class OrderedCollection. Basically, I've got a string
> object whose contents are the name of some class, and I need to be
> able to send class-side messages like "new" to whichever class
> is named in the string, but I can't seem to find a mechanism for
> doing this.
> > Thanks,
> -Kevin
<< File: ENVELOPE.TXT >>
More information about the Squeak-dev
mailing list
|