[squeak-dev] adding a method thru code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] adding a method thru code

kemal asad-syed
I am trying to add a method to a class using code
let's say if i want to add to the Myclass class the following method:
SelfGeneratedmethode:
^'self generated methode on fri26 sept 2008'.

".
I think with smalltalk it should be possible but i am stuck Any help is welcome. I did
Thanks.
Kemal


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] adding a method thru code

Rob Rothwell
Kemal,

Try:

MyClass class>>createMethod: methodName

self compile: methodName , '
^''this is a code-generated method''' classified: 'generated'.

Make sure you put the method on the class side, or else do a self class compile:classified:

Check out the "Terse Guide to Squeak," attached...

Take care,

Rob

On Fri, Sep 26, 2008 at 3:19 AM, kemal asad-syed <[hidden email]> wrote:
I am trying to add a method to a class using code
let's say if i want to add to the Myclass class the following method:
SelfGeneratedmethode:
^'self generated methode on fri26 sept 2008'.

".
I think with smalltalk it should be possible but i am stuck Any help is welcome. I did
Thanks.
Kemal







Terse Guide To Squeak.txt (87K) Download Attachment