How to call method by variable?

Benoit St-Jean bstjean at yahoo.com
Mon Jan 20 00:49:03 UTC 2003


--- Ralf Bokelberg <squeak at bokelberg.de> wrote:
> This surely has been answered already, 
> but i couldn't find it, sorry. 
> 
> I want to call a method of an object, 
> whose name is in a variable. 
> 
> The following script is not correct, 
> but it shows (hopefully) my intention. 
> 
> meth1
>     Transcript show: 'meth 1 called'.
> 
> meth2
>     Transcript show: 'meth 2 called'.
> 
> initialize
>     actMeth _ meth1
> 
> step 
>     "I want to call the method which is in actMeth"
>     self actMeth. 
> 
> How can this be done ? 


 initialize
     actMeth _ #meth1


 step 
     "I want to call the method which is in actMeth"
     self perform: actMeth. 
  

=====
-------------------------
Benoit St-Jean
bstjean at yahoo.com
Yahoo! Messenger: bstjean
http://cactus.swiki.net
-------------------------



More information about the Squeak-dev mailing list