Incude Ruby files instead of all of your code in a one file. Single file hold all of your code just won’t do, except for small programs. Split file or files.
To prevent chaos, you can include ruby files and organize. If your program is object orientated, you can create a file for every class.
The load method includes a Ruby file, each time a method is executed:
To be clear: the load method add a ruby file into your code, every time a script is executed. It does not work like a module or library.
The require methods loads the given file only once.
If you want to load a module, use require().
To execute code, use load().
Require doesn’t use the rb extension (filename.rb), because not all extensions end with .rb.
Create two files in the same directory, one named example.py
and another file named hello.rb
When executing, it will load hello.rb and call its method.