Skip to content

Instantly share code, notes, and snippets.

@julioterra
Created October 3, 2011 05:44
Show Gist options
  • Select an option

  • Save julioterra/1258509 to your computer and use it in GitHub Desktop.

Select an option

Save julioterra/1258509 to your computer and use it in GitHub Desktop.
capturing return values from yield
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