Skip to content

Instantly share code, notes, and snippets.

@infynyxx
Created May 18, 2010 18:04
Show Gist options
  • Save infynyxx/405307 to your computer and use it in GitHub Desktop.
Save infynyxx/405307 to your computer and use it in GitHub Desktop.
a = function () {
for (var i = 0; i < 5; i++) {
print(i);
}
}
//expected: print 0 to 4
//value: prints entire function instead of executing it
@mdirolf
Copy link

mdirolf commented May 18, 2010

this prints the entire function because you never call it. so it just prints the result of the last statement/expression, which is the variable a itself. if you then do:

a()

you will get the results printed. I don't think anything else makes sense here - you're defining the function not calling it.

@infynyxx
Copy link
Author

ok! that was a dumbest mistake

@mdirolf
Copy link

mdirolf commented May 18, 2010

no worries - glad it makes sense now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment