Skip to content

Instantly share code, notes, and snippets.

@ihower
Created July 30, 2012 02:48
Show Gist options
  • Save ihower/3203697 to your computer and use it in GitHub Desktop.
Save ihower/3203697 to your computer and use it in GitHub Desktop.
def foo
111
rescue
222
ensure
333
end
puts foo # got 111, why????
def bar
111
rescue
222
ensure
return 333
end
puts bar # got 333
@zlx
Copy link

zlx commented Jul 30, 2012

Write in The Ruby Programming Language#163
Note that ensure clause does not alter the return value of a method unless it explicitly uses a return statement

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