Created
March 10, 2012 11:00
-
-
Save Araq/2011157 to your computer and use it in GitHub Desktop.
closure issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var funcs: seq[proc (): int {.closure.}] = @[] | |
proc main() = | |
var i = 0 | |
while i <= 10: | |
funcs.add((proc (): int = | |
var x = i | |
return x * x)) | |
inc i | |
main() | |
echo(funcs[3]()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment