the12 the12 - 29 days ago 9
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.

i.e.:

onefile.rb:

require "secondfile"


secondfile.rb:

xxx


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

From the documentation:

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

http://apidock.com/ruby/Kernel/require