[Newbies] How to access a Squeak class

Warakorn Paphrawat warakorn_paphrawat at yahoo.com
Tue Jan 16 13:41:50 UTC 2007


This doesn't work either, because again (Smalltalk at: aClassName) is returning just a ByteString but not (e.g.)     Object class    or   (e.g.) ClassBuilder class .

Lets assume in the calling method is written:
returnSuperClass: '#Object'.
Note: the Argument must be an instance of String.

returnSuperClass: aClassName
|aSuperClass|

aSuperClass := (Smalltalk at: aClassName) superclass.

^ aSuperClass.

Nope, this does'nt work.

Herbert König <herbertkoenig at gmx.net> wrote: Hello Warakorn,

try:
Smalltalk at: #MonthMorph inspect

Cheers

Herbert       mailto:herbertkoenig at gmx.net
WP> Hi !
WP> Actually it is probably a very simple Squeak concept which I haven't understood, yet.

WP> Serving as an simple example, I would like to write a method,
WP> which accepts a Class as argument and which return the Superclass
WP> of that Class.
WP> The problem is that the argument must be an instance of
WP> String, that means  the argument aClassName  contains an actual
WP> class name (e.g. aClassName = 'Object'. or aClassName =
WP> 'ClassBuilder'), however, this is just a String object.

WP> returnSuperClass: aClassName
WP> |aSuperClass|

WP> aSuperClass := aClassName superclass.

WP> ^ aSuperClass.

WP> Obviously this method won't work, because aClassName is just
WP> an instance of ByteString. And instances of ByteString cannot
WP> understand the message superclass.

WP> So I need the actual class object  which the content of the String aClassName represents.
WP> How can I achieve ? Or how can I make this method correct ?
WP> (it is imperative, that the argument aClassName is a String).

WP> Thanks for you help in advance.


WP> Best Regards
WP> Warakorn



WP> Have a burning question? Go to Yahoo! Answers and get answers from real people who know.




_______________________________________________
Beginners mailing list
Beginners at lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


 
---------------------------------
Don't get soaked.  Take a quick peak at the forecast 
 with theYahoo! Search weather shortcut.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20070116/a03cedc6/attachment.htm


More information about the Beginners mailing list