Last active
December 15, 2015 14:09
-
-
Save dcunited001/5272228 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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