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

Michael Davies mykdavies+squeak at gmail.com
Wed Feb 7 18:06:37 UTC 2007


I was browsing some of the Magritte source code, when I saw a message
that confused me:
	selectors := anObject class allSelectors
		select: #isDescriptionSelector.

I couldn't understand how you could pass a Symbol to #select: instead
of a block -- certainly the definition of Collection>>select: implies
it should only take a block. But trying it for myself, I see it works
-- eg
{ 1. 2. 3. 4. } select: #even.

can be used in place of:

{ 1. 2. 3. 4. } select: [ :each | each even ]

Given how much simpler this looks, I was surprised I'd not seen this
usage before, and searching for senders of #select: shows that the
wordier version seems to be generally preferred.

So my question is: is this a usage I should adopt or avoid?

Cheers,
Michael


More information about the Beginners mailing list