Skip to content

Instantly share code, notes, and snippets.

@ignacy
Created October 11, 2011 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ignacy/8d0050e9f6221f8b874c to your computer and use it in GitHub Desktop.
Save ignacy/8d0050e9f6221f8b874c to your computer and use it in GitHub Desktop.
Methods taking multiple blocks
class Multiple
def multiple(success)
rand(2).odd? ? success.call : yield
end
end
i = Multiple.new
10.times do
i.multiple -> { puts "success" } { puts "fail"}
end
@rogerbraun
Copy link

Nice trick for getting this syntax to work, but won't scale for more blocks.

@JEG2
Copy link

JEG2 commented Oct 17, 2011

This is what Ruby offers us for free. The goal was to improve on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment