logo       

how to create an object (of a selection of classes): msg#00106

lang.smalltalk.squeak.beginners

Subject: how to create an object (of a selection of classes)

Best List,

Im very curious to the the 'smalltalk way' to write the following code:

| shape morph |
(2 atRandom == 1)
ifTrue: [shape := RectangleMorph]
ifFalse: [shape := EllipseMorph].
morph := shape new.

I've tried something like:

(#(EllipseMorph RectangleMorph) at: (2 atRandom)) new.

But thats too silly ? Is there some connection to get a class from a symbol
? Or is that the wrong direction ?


Thanks in advance,


- Jeroen - aspiring squeaker.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise