Created
January 26, 2015 06:24
-
-
Save bion/6abe02ceec9d99c85561 to your computer and use it in GitHub Desktop.
Ruby concepts 2
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
| class Foo | |
| def double_then_yield(num, &block) | |
| block.call(num * 2) | |
| end | |
| end | |
| foo = Foo.new | |
| result = foo.double_then_yield 5 do |num| | |
| num + 1 | |
| end | |
| puts "result is #{result}" # result is 11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment