Having a Ruby block/command silently fail without a blank 'rescue' block

Viewed 7024

Say I want a call to be run, and if it fails, it's no big deal; the program can continue without a problem. (I know that this is generally bad practice, but imagine a hypothetical, quick one-off script, and not a large project)

The way I've been taught to do this was:

begin
  thing_to_try
rescue
  # awkward blank rescue block
end
next_thing

Of course, there are other ways to do this, including using ensure and things like that. But is there a way to get a method call/block to silently fail without a messy blank block?

3 Answers
Related