Lukas Renggli wrote: > > 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 ]. > ... ] ] >
If you don't care about performance, you can use "Continuation currentDo:" instead of "self escaper:". :-) As an additional bonus, continuations support both 0- and 1-argument value, so that you can return a value if you wish. Paolo -- View this message in context: http://www.nabble.com/How-to-exit-loops--tp18056234p18636867.html Sent from the Gnu - Smalltalk mailing list archive at Nabble.com. _______________________________________________ help-smalltalk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-smalltalk
