Does the Ruby rescue
statement modifier work with require
?
irb(main):001:0> require 'a' rescue nil
LoadError: no such file to load -- a
from (irb):1:in `require'
from (irb):1
from :0
Does the Ruby rescue
statement modifier work with require
?
irb(main):001:0> require 'a' rescue nil
LoadError: no such file to load -- a
from (irb):1:in `require'
from (irb):1
from :0
You can rescue from a
LoadError
you just need to use thebegin/end
style and not use the inlinerescue
:This works as you expect: