开发者

Ruby require error

I'm trying to call the file from the file cpu.rb from开发者_开发问答 main.rb:

require 'rubygems'
require 'cpu.rb'

But it does not work. I use Netbeans and Ruby 1.9.2. What's the problem?


Ruby 1.9.2 does not include the current file's directory in $LOAD_PATH.

You can try using require_relative instead:

require_relative 'cpu.rb'

Or you can supply the actual path:

require './cpu.rb'

Or you can add the current file's directory to the load path:

$LOAD_PATH.unshift File.dirname(__FILE__)
require 'cpu.rb'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜