[squeak-dev] orMoreDo:

Stéphane Rollandin lecteur at zogotounga.net
Thu Dec 9 17:11:44 UTC 2010


Hello,


I just wanted to share the following method, which comes in handy when 
one wants a receiver to be considered always as a collection, possibly 
by lifting it as a singleton (reminds you of something, Chris ?)

Object>>orMoreDo: aBlock
	^ aBlock value: self

Collection>>orMoreDo: aBlock
	^ self do: aBlock


example:

4 orMoreDo: [:x | Transcript show: x + 1]
(4 to: 7) orMoreDo: [:x | Transcript show: x + 1]


I don't know if this is generally useful; it has proven useful to me at 
least...


Stef



More information about the Squeak-dev mailing list