Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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
Add Comment
Please, Sign In to add comment