Quoting constructs: Difference between revisions

Content added Content deleted
Line 432: Line 432:


====Blocks====
====Blocks====
Somewhat between literal constants and instantiated object are blocks which represent a closure (lambda function). Here, the code object is constructed as literal at compile time, and a closure object (which wraps the code plus the visible variables) into an object at execution time.
Somewhat between literal constants and instantiated object are blocks, which represent a closure (lambda function). Here, the a object is constructed as literal at compile time, and a closure object (which wraps the code plus the visible variables) into an object at execution time.
Blocks thus represent a piece of code which can be stored in an instance variable, passed as argument or returned from a method.
Blocks thus represent a piece of code which can be stored in an instance variable, passed as argument or returned from a method.
<br>Block syntax is very compact:
<br>Block syntax is very compact: