Created
January 21, 2015 01:50
-
-
Save kmdsbng/3bb3405c080483c68b88 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
| a = 1.tap {|i| puts i + i} | |
| a # => 1 | |
| b = 1.tap {|i| break i + i} | |
| b # => 2 | |
| # >> 2 | |
| #lam = lambda {|i| return 1} | |
| def use_proc | |
| pro = proc {|i| | |
| return i + 1 | |
| } | |
| result = pro.call(1) | |
| return result + 3 | |
| end | |
| use_proc # => 2 | |
| def use_lambda | |
| lam = lambda {|i| | |
| return i + 1 | |
| } | |
| result = lam.call(1) | |
| return result + 3 | |
| end | |
| use_lambda # => 5 | |
| # >> 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment