Skip to content

Instantly share code, notes, and snippets.

@dacc
Created May 18, 2010 02:56
Show Gist options
  • Save dacc/404553 to your computer and use it in GitHub Desktop.
Save dacc/404553 to your computer and use it in GitHub Desktop.
ruby-1.9.1-p378 > # i'd like this to print 0, 1, 2, 3. not sure how to change things.
ruby-1.9.1-p378 >
ruby-1.9.1-p378 > ps = []
=> []
ruby-1.9.1-p378 > for i in 0..3
ruby-1.9.1-p378 ?> ps.push(proc { puts i })
ruby-1.9.1-p378 ?> end
=> 0..3
ruby-1.9.1-p378 >
ruby-1.9.1-p378 > for p in ps
ruby-1.9.1-p378 ?> p.call
ruby-1.9.1-p378 ?> end
3
3
3
3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment