Closures/Value capture: Difference between revisions
Content added Content deleted
Line 579: | Line 579: | ||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA 4. |
ELENA 4.x : |
||
<lang elena>import system'routines; |
<lang elena>import system'routines; |
||
import extensions; |
import extensions; |
||
Line 585: | Line 585: | ||
public program() |
public program() |
||
{ |
{ |
||
var functions := Array.allocate(10).populate:(int i => |
var functions := Array.allocate(10).populate:(int i => (^ i * i) ); |
||
functions.forEach:(func) { console.printLine(func()) } |
functions.forEach:(func) { console.printLine(func()) } |