explicit return from a block

Stéphane Rollandin lecteur at zogotounga.net
Tue Jun 27 08:00:37 UTC 2006


example

	| cont j |

	cont _ Continuation current.
	cont isNumber ifTrue: [^ cont].
	
	1 to: 5 do: [:i |
		j _ i.
		i = 3 ifTrue: [cont value: i]].

	^ j.


this return 3 via ^cont so you can actually do whatever you want with 
that value, just as you asked.

... you can find class Continuation in Seaside.

Stef


Viktor Svub wrote:
> Is there any way to explicitly return from a BlockContext/BlockClosure
> (like ^some-expression in methods) but without returning from the parent
> context (method)? I'm beginning to figure out how to avoid the need for
> "break&continue" in loops, and i know that i can even avoid the need for
> explicit return converting the block in question in a method, but there
> are places where a long block is much more convenient...
> thanks
> vsv
> 




More information about the Squeak-dev mailing list