Skip to content

Instantly share code, notes, and snippets.

@rbxbx
Created January 10, 2011 15:32
Show Gist options
  • Select an option

  • Save rbxbx/772898 to your computer and use it in GitHub Desktop.

Select an option

Save rbxbx/772898 to your computer and use it in GitHub Desktop.
#closures as I currently understand them
free_variable = 1
clos = lambda { p "I'm a closure because I hold on to #{free_variable += 1}" }
non_clos = lambda { |x| p "I'm not a closure :(, because #{x += 1} hasn't changed" }
p clos.call
p clos.call
p non_clos.call(free_variable)
p non_clos.call(free_variable)
p non_clos.call(free_variable)
p clos.call
p clos.call
p clos.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment