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?
To use it, you launch the irb executable and type your Ruby code at the prompt. IRB evaluates the code you type and displays the results. IRB gives you access to all of Ruby's built-in features, as well as any libraries or gems you've installed.
To access IRB, just type irb in the terminal. IRB allows you to do anything you can do in a Ruby file. For instance, you can do math, get the time by typing Time. now , or print text to the screen.
Open Interactive Ruby Open up IRB (which stands for Interactive Ruby). If you're using macOS open up Terminal and type irb, then hit enter. If you're using Linux, open up a shell and type irb and hit enter. If you're using Windows, open Interactive Ruby from the Ruby section of your Start Menu.
IRB stands for “interactive Ruby” and is a tool to interactively execute Ruby expressions read from the standard input. The irb command from your shell will start the interpreter.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With