load works on local path, require doesn't

前端 未结 2 1845
孤独总比滥情好
孤独总比滥情好 2021-02-07 01:44

loadee.rb

puts \'> This is the second file.\'

loaddemo.rb

puts \'This is the first (master) program file.\'
load \'loadee.rb         


        
2条回答
  •  太阳男子
    2021-02-07 02:01

    Providing a path with the filename seemed not to work for me, and I didn't want to cram a bunch of paths into my $LOAD_PATH.

    Checking out the documentation, I found require_relative.

    require_relative 'loadee'
    

    Works in both 1.9.2 and 2.1.2.

    The documentation indicates that require is not intended to search relative paths at all, and neither is load.

提交回复
热议问题