Obtaining traits by name

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Obtaining traits by name

keith1y
Is there a preferred method for obtaining a Trait by name. I see that
Trait goes to the troble of defining #environment.

Trait named: blah etc can be used to define a trait. Is there a method
such as Trait named: 'myTrait'  for obtaining a Trait?

Smalltalk at: #TMyTrait works, but I am wondering if there is a better way.

thanks in advance

Keith

               
___________________________________________________________
Try the all-new Yahoo! Mail. "The New Version is radically easier to use" – The Wall Street Journal
http://uk.docs.yahoo.com/nowyoucan.html

Reply | Threaded
Open this post in threaded view
|

Re: Obtaining traits by name

Adrian Lienhard
Hi Keith,

Obtaining traits works the same as for classes, i.e., they are also  
stored in the system dictionary. Instead of Smalltalk>>at: you can  
also use Smalltalk>>classOrTraitNamed:.
Of course, if you do not need to obtain the trait dynamically from a  
string, you can just type it in the method source or the doit.

Adrian

On Mar 8, 2007, at 08:04 , Keith Hodges wrote:

> Is there a preferred method for obtaining a Trait by name. I see  
> that Trait goes to the troble of defining #environment.
>
> Trait named: blah etc can be used to define a trait. Is there a  
> method such as Trait named: 'myTrait'  for obtaining a Trait?
>
> Smalltalk at: #TMyTrait works, but I am wondering if there is a  
> better way.
>
> thanks in advance
>
> Keith
>
>
> ___________________________________________________________ Try the  
> all-new Yahoo! Mail. "The New Version is radically easier to use" –  
> The Wall Street Journal http://uk.docs.yahoo.com/nowyoucan.html
>