Skip to content

Instantly share code, notes, and snippets.

@dcunited001
Last active December 15, 2015 14:09
Show Gist options
  • Save dcunited001/5272228 to your computer and use it in GitHub Desktop.
Save dcunited001/5272228 to your computer and use it in GitHub Desktop.
def foo(lam, bar)
lam.call
end
# hoge is japan's foobar - thanks @cwgem
bar = 'hoge'
# lambda retains the bindings from it's original declaration
el = lambda { puts bar*5 }
p = Proc.new { puts bar*5 }
#these all output the same thing
foo(lam, 'quid')
foo(lam, 5)
el.call
#and so do these ..
foo(p, 'quid')
foo(p, 5)
p.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment