RosettaCodeData/Task/Loops-Nested/Smalltalk/loops-nested-3.st
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

10 lines
422 B
Smalltalk

!Block methodsFor:'looping'!
loopWithExit
"the receiver must be a block of one argument. It is evaluated in a loop forever,
and is passed a block, which, if sent a value:-message, will exit the receiver block,
returning the parameter of the value:-message. Used for loops with exit in the middle."
|exitBlock|
exitBlock := [:exitValue | ^ exitValue].
[true] whileTrue:[ self value:exitBlock ]