Why can't blocks return?

Julian Fitzell julian at beta4.com
Sun May 4 05:53:57 UTC 2003


Blocks can return, they just return from the method in which they were 
defined.  Think of:

foo
   someVar ifTrue: [^ false].

   "do some other stuff"

   ^ true


When you call #value on a block, the result of the last statement 
executed in the block is returned.

Julian

Derek Brans wrote:
> And is there any way to stop execution like a return does in a method?
>  
> Thank you.
>  
> Derek Brans
> Nerd on a Wire
> Web design that's anything but square
> http://www.nerdonawire.com
> phone: 604.874.6463
> mailto: brans at nerdonawire.com <mailto:brans at nerdonawire.com>
> 
> 
> ------------------------------------------------------------------------
> 
> 


-- 
julian at beta4.com
Beta4 Productions (http://www.beta4.com)



More information about the Squeak-dev mailing list