[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] Re: How to exit loops?
From: |
Lukas Renggli |
Subject: |
Re: [Help-smalltalk] Re: How to exit loops? |
Date: |
Sun, 22 Jun 2008 19:03:57 +0200 |
My preferred way is the following:
Add the following method to Object (or somewhere else):
Object>>escaper: aBlock
^ aBlock value: [ ^ nil ]
Then implement your loop like this:
self escaper: [ :break |
1 to: 10 do: [ :x |
x = 3 ifTrue: [ break value ].
... ] ]
Cheers,
Lukas
--
Lukas Renggli
http://www.lukas-renggli.ch