On 07.11.2011 15:33, Henrik Sperre Johansen wrote:
On 07.11.2011 15:29, Markus Rother 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.
Such that:
#Foo asClass new -> a Foo
whereas asClass is the method I am looking for.
(self environment at: #Foo) new -> a Foo
Cheers,
Henry
Or if you want it to only resolve Symbols which are actually classes:
self environment classNamed: #Foo
Example:
self environment at: #Transcript -> a TreadSafeTranscript
self environment classNamed: #Transcript -> nil
Also, if not found, classNamed: returns nil, while at: raises an error.
Cheers,
Henry