Skip to content

Instantly share code, notes, and snippets.

@hannestyden
Created August 11, 2014 10:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hannestyden/7994c4b2f2fbb904a7df to your computer and use it in GitHub Desktop.
Save hannestyden/7994c4b2f2fbb904a7df to your computer and use it in GitHub Desktop.
class E < StandardError; end
def m(raise_exception)
y do
r(raise_exception)
:nothing_raised
end
rescue E
:rescued
end
def n(raise_exception)
y do
begin
r(raise_exception)
:nothing_raised
rescue E
:rescued
end
end
end
def r(raise_exception)
raise E if raise_exception
end
def y
yield
end
m(true) # => :rescued
m(!true) # => :nothing_raised
n(true) # => :rescued
n(!true) # => :nothing_raised
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment