Closures/Value capture: Difference between revisions

Content added Content deleted
Line 550: Line 550:


=={{header|Elena}}==
=={{header|Elena}}==
ELENA 3.4 :
ELENA 4.x :
<lang elena>import system'routines.
<lang elena>import system'routines;
import extensions;
public program
public program()
{
[
var functions := Array new(10); populate(:i)<int>( [ ^ i * i ] ).
var functions := Array.allocate(10).populate:(int i => (^ i * i) );
functions forEach(:func) [ console writeLine(func()) ]
functions.forEach:(func) { console.printLine(func()) }
]</lang>
}</lang>
{{out}}
{{out}}
<pre>0
<pre>0