Closures/Value capture: Difference between revisions

m
(added Arturo)
imported>Arakov
Line 592:
public program()
{
var functions := Array.allocate(10).populate:(int i => { ^ i * i} );
functions.forEach:(func) { console.printLine(func()) }
Line 607:
64
81</pre>
 
=={{header|Elixir}}==
<syntaxhighlight lang="elixir">funs = for i <- 0..9, do: (fn -> i*i end)
Anonymous user