Ruby: How to load a file into interactive ruby console (IRB)?

nbonbon picture nbonbon · Oct 28, 2012 · Viewed 78.9k times · Source

I am using IRB (interactive ruby console) to learn how to program with Ruby. How do I load a file into the console if I write my programs in a text editor first?

Answer

PhilG picture PhilG · Jan 9, 2013

If you only need to load one file into IRB you can invoke it with irb -r ./your_file.rb if it is in the same directory.

This automatically requires the file and allows you to work with it immediately.