Re: What is the use of load and require in Ruby? The require method is used to run one Ruby program from another. The following sample simulates a short conversation between my first son and myself. Here, I have created a file named "me.rb", which represents me initiating and keeping the conversation going.
# I have to start the conversation
puts '[me] Hey A, how was your day?'
require 'son1.rb'
Use load when you expect a different result. This can be useful when your program is always running and you would like to update some code without having to shut it down. For example, when you are developing a Rails application, you want to run the Rails server then test some functionality, make some updates, test the updates, and repeat the test-update process all without restarting the server each time. |