the12
the12

Reputation: 2415

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?

Upvotes: 4

Views: 778

Answers (1)

mikdiet
mikdiet

Reputation: 10018

From the documentation:

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

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

Upvotes: 3

Related Questions