Skip to content

Files

Latest commit

 

History

History
34 lines (25 loc) · 737 Bytes

Lint-EnsureReturn.md

File metadata and controls

34 lines (25 loc) · 737 Bytes

Pattern: Use of return in ensure block

Issue: -

Description

If you explicitly return from a method inside an ensure block, the return will take precedence over any exception being raised, and the method will return as if no exception had been raised at all. In effect, the exception will be silently thrown away.

Examples

# bad

begin
  do_something
ensure
  do_something_else
  return
end
# good

begin
  do_something
ensure
  do_something_else
end

Further Reading