[Newbies] anObject select: #aMethodName -- is this good Squeak?

Giovanni Corriga giovanni at corriga.net
Wed Feb 7 23:22:11 UTC 2007

Il giorno mer, 07/02/2007 alle 13.42 -0500, Ron Teitelbaum ha scritto:
> Hi Michael,
> It's a trick.  It only works because #value: is implemented on symbol as: 
> Symbol>>value: anObject
> 	^anObject perform: self.
> So the following works too.
> #asUppercase value: 'I am a trick'
> My suggestion is that you shouldn't follow such tricks.  Although I do it
> too sometimes with things like.
> aDictionary at: #foo ifAbsent: nil.
> Since nil responds self to #value it seems redundant to me to put the nil in
> a block so that it can return nil when the block is evaluated with #value.
> Even though in this case the execution is faster but in the case of sending
> a symbol to select it is slower.
> In both cases it is harder to read so in my opinion it is best to stick with
> arguments that are expected.

Not to mention the fact that if you use a Symbol instead of a block,
that use won't be listed in the Senders browser.


More information about the Beginners mailing list