The following are some snippets of documentation for Kernel :
Kernel loading
Loads and executes the Ruby program in the file filename ...
Kernel # required
Loading name ...
I know that there are differences between require and load , for example:
require will be bound to the rb extension, and load will notrequire save the ruby file path inside $LOADED_FEATURES aka $" , but load will notrequire will look for $LOADED_FEATURES before “uploading” the file again until load is
I am interested to know about the difference between the word “load” and the word “performs”.
The documentation seems to be two different things. For me, "load" will mean "Hey, I know about this file now," while "execute" will mean "Hey, I know about this file now, and I will also run all the commands."
But I do not think this is right.
For example, given the following structure:
$ tree . ├── bar.rb ├── baz.rb └── foo.rb 0 directories, 3 files
with foo.rb:
$LOAD_PATH << __dir__ require 'bar' load 'baz.rb'
bar.rb:
puts "Inside of bar..."
baz.rb:
puts "Inside of baz..."
When I ran foo.rb , I would expect "Inside of baz ..." to print, but not "Inside of bar ..." because load "loaded and executed", and require just "loaded". But what actually happens, both seem to be "doable":
$ ruby foo.rb Inside of bar... Inside of baz...
So is there any difference between “downloading” and “executing” a ruby file?
source share