the12 the12 - 1 year ago 83
Ruby Question

How does load/require/require_relative handle a file with no file extension?

I have been using a tutorial that uses require with a file that does not have a file extension.



require "secondfile"



In my mind, I'm thinking there is potential for conflict (having two files with the same name, but different extensions). So naturally was wondering how Ruby would ultimately handle determining what file extension to use with load/require/require_relative when the file has no file extension?

Answer Source

From the documentation:

Ruby tries adding “.rb”, “.so”, and so on to the name until found.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download