Ruby Constructs Flashcards
Basic File Inclusion
- require
Loads a file from $LOAD_PATH or $:.
File type suffix “.rb” is assumed.
Specify directory of the file if it is not in load path.
File is loaded only once for multiple calls to the same file.
xjdhsmdh
hjdjdjdj
djdhdhdh
ydjdjdjfjfjfj
fjjdjfjfkfjxhdnchdmcjf
fjfjfjfjfjfjfjgjfmf
fjfjfjfjfjfj
fjfjfjf
fjfjfjfjfjfjf
fjfjfjf
fjfjfj
fjfjfjfjf
jfjfjfj
cjcjfjfjc
hfjfjfjfjf
fhnfjcjfj
Basic File Inclusion
- require_relative
Loads specified file relative to file loading the file.
File type suffix “.rb” is assumed.
File is loaded only once for multiple calls to the same file.
Basic File Inclusion
- load
loads local files like require_relative.
Multiple calls loads the file multiple times.
Logic and Include Code
require, require_relative and load can be used anywhere in the code.
The code in the loaded file is executed at the point in the script where file is loaded.
Nested Inclusions
Included files can also use load, require and require_relative.