Why doesn't relative_require work on Ruby 1.8.6?

后端 未结 2 771
猫巷女王i
猫巷女王i 2020-12-16 13:29

I\'m learning Ruby (using version 1.8.6) on Windows 7.

When I try to run the stock_stats.rb program below, I get the following error:



        
2条回答
  •  误落风尘
    2020-12-16 14:09

    Edit:

    Back in the days where this question was asked it referred to Ruby 1.8.6 where there was no require_relative. By now Ruby 1.8.6 is outdated and shouldn't be used anymore.

    Original:

    There is simply no method name require_relative. You can use require there aswell.

    The require_relative function is included in an extension project to the Ruby core libraries, found here: http://www.rubyforge.org/projects/extensions

    You should be able to install them with gem install extensions. Then in your code add the following line before the require_relative:

    require 'extensions/all'
    

提交回复
热议问题