[squeak-dev] orMoreDo:

Chris Muller asqueaker at gmail.com
Thu Dec 9 21:17:52 UTC 2010


How dare you!?   ;-)

2010/12/9 Stéphane Rollandin <lecteur at zogotounga.net>:
> 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