Throw exception when required file does not exist?
-
I wanted to do this:
begin require 'file' rescue # endBut it does work? Why not?
I know I can do it other ways, but I'm just curious if there's a reason for the behavior.
-
rescue with no argument will default to
StandardError.
What you want is:begin require 'foods' rescue LoadError puts "not there" end -
Ah! Thank you Adam.
But I think I may just be being too lazy to check if the files exists...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement