[Newbies] Re: break out of do
Bert Freudenberg
bert at freudenbergs.de
Fri Oct 3 17:47:47 UTC 2008
Am 03.10.2008 um 09:27 schrieb Randal L. Schwartz:
>>>>>> "Nicolas" == Nicolas Cellier <ncellier at ifrance.com> writes:
>
> Nicolas> For the fun of it, see also
>
> Nicolas> http://article.gmane.org/gmane.comp.lang.smalltalk.gnu.general/3375/match=break
>
> Oww. I remember that. It makes my head hurt.
>
> You could even go further:
>
> Object >> valuedEscaper: aBlock
> ^ aBlock value: [ :finalValue | ^finalValue ]
>
> ...
>
> found := self valuedEscaper: [:escape |
> 1 to: 10 do: [ :x |
> x = 3 ifTrue: [escape value: true].
> ]
> false].
>
> Oh geez. I think I just reinvented continuations. :)
That would be a perfect opportunity to employ
#valueWithPossibleArgument:.
- Bert -
More information about the Beginners
mailing list