1,333
edits
| Line 457: | Line 457: | ||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
for (var i = 0; i < 10; i += 1) | for (var i = 0; i < 10; i += 1) { | ||
(func { | (func { | ||
# this is an anonymous closure that will be able to "save" the value of i | # this is an anonymous closure that will be able to "save" the value of i | ||
| Line 463: | Line 463: | ||
append(result, func print(i)); # this function will use the local i that we saved | append(result, func print(i)); # this function will use the local i that we saved | ||
})(); # call immediately | })(); # call immediately | ||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
edits