Loading Ruby Files Into Memory

In this tutorial, we will learn how to load .rb files into memory. Ruby files need to be loaded if the methods inside them can be made to be called from irb.

In order to load files, you need to use load "path_to_file" command. I am going to load a file named "generate_random_n_digit_number.rb" which is located at "C:\\Users\\Amma\\Desktop"



I type in load "C:\\Users\\Amma\\Desktop\\generate_random_n_digit_number.rb" in irb and if the loading was successful, it should return back "true"



This makes the ruby files' methods available for us to use. For example, I can use generate_random_number method of the generate_random_number_with_n_digits.rb file from irb. Here is how