Search the web
Sign In
New User? Sign Up
squeak
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Class Name   Message List  
Reply | Forward Message #94871 of 143988 |
Re: Class Name

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




Tue May 24, 2005 4:59 pm

hmm@...
Send Email Send Email

Forward
Message #94871 of 143988 |
Expand Messages Author Sort by Date

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,...
BELEM Mahamadou
mabelem2003@...
Send Email
May 24, 2005
11:51 am

... myCar := Car new. myCar perform: #run ... This looks right actually. For eg. 1 className "answers 'SmallInteger'" You can try reading the books found at...
Yar Hwee Boon
hboon@...
Send Email
May 24, 2005
1:21 pm

... What Mahamadou tried to achieve is more like this: myClassName := 'Car'. myObject := (Smalltalk at: myClassName asSymbol) new. myObject run However, this...
Hans-Martin Mosner
hmm@...
Send Email
May 24, 2005
5:00 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help