您的位置:首页 > 产品设计 > UI/UE

load & require

2015-05-29 16:44 330 查看
The 'require' method will not look in the current directory for files to load(but you can use require './test.rb' to look in the current directory), but 'load' will.

If called more than once, 'require' will not reload the file while 'load' will. Suppose you're writing some code in a file and require it into irb. But it's failed, you fixed the failure and require it again, you won't get the fixed version. You need to use load to get the fixed version. So use 'require' in script file and 'load' in irb.

The 'require' method figures out the extension('.rb', '.so', '.dll'..) for you, but 'load' won't. So you need to use them like this:

require 'test'
load 'test.rb'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: