Class Name
Hans-Martin Mosner
hmm at heeg.de
Tue May 24 16:59:54 UTC 2005
Yar Hwee Boon wrote:
>
> On 24-May-05, at PM 07:51, BELEM Mahamadou wrote:
>
>> Hello
>>
>> 1) It is possible to call a methode of a class by using a string?
>>
>> Example : myString := 'car'. /where car is a class name.
>>
>> I want by using myString, call the "run" methode of a object of car :
>> myString run.
>
>
> myCar := Car new.
> myCar perform: #run
What Mahamadou tried to achieve is more like this:
myClassName := 'Car'.
myObject := (Smalltalk at: myClassName asSymbol) new.
myObject run
However, this will of course get him into the debugger if there is no class named 'Car' in the system, so for real life
production code there should be some error checking etc.
Cheers,
Hans-Martin
More information about the Squeak-dev
mailing list
|