Created
October 22, 2014 22:07
-
-
Save tlehman/6c55032412417ac5c330 to your computer and use it in GitHub Desktop.
procs vs lambdas (making ruby blocks into objects using proc or lambda)
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
| a = proc { return 1 } | |
| # ==> #<Proc:0x007f96d280a118@(irb):1> | |
| b = lambda { return 1 } | |
| # ==> #<Proc:0x007f96d3002438@(irb):3 (lambda)> | |
| a.call | |
| # =LocalJumpError: unexpected return | |
| # = from (irb):1:in `block in irb_binding' | |
| # = from (irb):5:in `call' | |
| # = from (irb):5 | |
| # = from /usr/bin/irb:12:in `<main>' | |
| b.call | |
| # ==> 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment