On 11/07/2011 11:08 PM, Stéphane Ducasse wrote:
The issue I could not solve on my own is this:
I would like to instantiate from symbols. My use-case is a collection of class
names which I want to ask to return one instance each.
why are you trying to do?
because symbols are not done to be instantiated like that.
aString asSymbol is instantiating symbols for you.
Stef
Thanks everybody for the kind, plenty and swift replies.
Here is what I was up to:
ChessBoard class>>newGame
| newBoard |
...
firstRow := #(Rook Knight Bishop Queen King Bishop Knight Rook).
1 to: 8 do: [ :col |
(newBoard at: 1 at: col) putFigure: (firstRow at: col)
asClass newWhite
].
...
Symbol>>asClass
^(Smalltalk classNamed: self)
I don't see how a string representation would have helped me here...?
Although, I am a noob, my intuition tells me that symbols are absolutely
fine, here - especially considering they are used precisely for that
purpose internally.
Greets,
Markus