How to call method by variable?

Ned Konz ned at bike-nomad.com
Mon Jan 20 02:40:09 UTC 2003


On Saturday 18 January 2003 06:22 am, Ralf Bokelberg 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
	self perform: actMeth

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list