Created
October 3, 2011 05:44
-
-
Save julioterra/1258509 to your computer and use it in GitHub Desktop.
capturing return values from yield
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 yielding_method | |
| puts “pre-yield” | |
| return_vals = yield(“message from yielding method”) | |
| puts “post-yield #{return_val}” | |
| end | |
| yielding_method do |i| | |
| puts “yield code block #{i}” | |
| str = “message from code block back to method” | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment