Skip to content

Instantly share code, notes, and snippets.

@saiday
Created July 29, 2015 18:08
Show Gist options
  • Select an option

  • Save saiday/151abb75d60aa10c635a to your computer and use it in GitHub Desktop.

Select an option

Save saiday/151abb75d60aa10c635a to your computer and use it in GitHub Desktop.
Ruby variable capture
a = []
for i in 1..3
a.push(lambda { i })
end
for f in a
print "#{f.call()}"
end
// output: 333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment