require load
When you want to run script from other file, or include library, you need to use require or load
Ruby system find library using relative path or absolute path or $LOAD_PATH setting.
If there are no file in these path, LoadErro has happened
Example
require "test.rb"
Difference between require and load
Condition | require | load |
---|---|---|
Run same file? | Only one time | Run every time to call load |
File Index | automatically added | not automatically |
I often require in sample source codes
require is similar with import in Objective-C.