Closures/Value capture: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (added Arturo) |
imported>Arakov |
||
Line 592: | Line 592: | ||
public program() |
public program() |
||
{ |
{ |
||
var functions := Array.allocate(10).populate:(int i => {^ i * i} ); |
var functions := Array.allocate(10).populate:(int i => { ^ i * i} ); |
||
functions.forEach:(func) { console.printLine(func()) } |
functions.forEach:(func) { console.printLine(func()) } |
||
Line 607: | Line 607: | ||
64 |
64 |
||
81</pre> |
81</pre> |
||
=={{header|Elixir}}== |
=={{header|Elixir}}== |
||
<syntaxhighlight lang="elixir">funs = for i <- 0..9, do: (fn -> i*i end) |
<syntaxhighlight lang="elixir">funs = for i <- 0..9, do: (fn -> i*i end) |