Skip to content

Instantly share code, notes, and snippets.

@undecided
Created August 24, 2012 09:12
Show Gist options
  • Save undecided/3447966 to your computer and use it in GitHub Desktop.
Save undecided/3447966 to your computer and use it in GitHub Desktop.
I got caught out by this. Anyone want to guess which string gets returned by this method?
def foo
raise "I iz a fool"
"But you don't know, man"
rescue Exception => e
"I caught your foolness"
ensure
"and I returned you a fish"
end
@undecided
Copy link
Author

If that boggled your noggin, try this for size:

def foo
    raise "I iz a fool"
    "But you don't know, man"
rescue Exception => e
    return "I caught your foolness"
ensure
    return "and I returned you a fish"
end

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