How to add a method via a method?

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

How to add a method via a method?

Dirk Klaschus
Hello, I want to write a message with a String-argument,
which adds a new method to MyClass:
---------------------------------------------------------
aMethod: 'MyClass'
---------------------------------------------------------  
 
This is what I wrote for aMethod: 
---------------------------------------------------------
aMethod: myClassWhichExist
 "comment stating purpose of message"

 myClassWhichExist compile: 'myMethod
 "comment stating purpose of message"
 | h |
 h:= ''Hello''.
 ^ h.' classified: 'delete'
---------------------------------------------------------
 
I get the following error message:           
---------------------------------------------------------
ByteString(Object)>>error:
error: aString
 "Throw a generic Error exception."
 ^ Error new signal: aString
---------------------------------------------------------
 
I understand that the class name 'myClassWichExist' as string-argument doesn't go along with the compile-message.  But to what do I need to convert the string-argument to make it work?
Many thanks in advance for your answers.
 
Olitizia

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to add a method via a method?

Bert Freudenberg
On Mar 9, 2008, at 22:40 , Dirk Klaschus wrote:

> I understand that the class name 'myClassWichExist' as string-
> argument doesn't go along with the compile-message.  But to what do  
> I need to convert the string-argument to make it work?

Smalltalk classNamed: myClassWichExist

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to add a method via a method?

Dirk Klaschus
Thanks, that helped.  Vielen Dank Bert.
 
Dirk

 
2008/3/10, Bert Freudenberg <[hidden email]>:
On Mar 9, 2008, at 22:40 , Dirk Klaschus wrote:

> I understand that the class name 'myClassWichExist' as string-
> argument doesn't go along with the compile-message.  But to what do
> I need to convert the string-argument to make it work?

Smalltalk classNamed: myClassWichExist

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners