Re: [Pharo-project] Instantiating from a Symbol
Nov. 7, 2011
2:41 p.m.
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
5380
Age (days ago)
5380
Last active (days ago)
0 comments
1 participants
participants (1)
-
Henrik Sperre Johansen