IRB stands for "Interactive Ruby." It's a Ruby shell or REPL. REPL stands for read–eval–print loop. It is a simple, interactive computer programming environment that takes user inputs (such as, in our case, snippets of Ruby code), evaluates them, and returns the result to the user. IRB is run by your computer's terminal. You can think of it as your Ruby playground or execution environment. You can open it up, insert code and execute it to see that code's return value.
IRB is not a file where you save your work. Any coding you do in the IRB console in your terminal will not get saved anywhere. It only exists temporarily. IRB is for testing, playing, manipulating your code so that you understand it better and solve problems with it.
IRB allows you to execute ruby in the terminal and you're going to get
comfortable using it to test and better understand your Ruby code. 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 up your terminal. (If you do not have a terminal on your computer you can use repl.it)
irb and hit
Now that you've started IRB, type the commands below to see how it works! Type each of the following lines into the IRB shell and press enter.
255 / 5
9 ** 2
puts "hello world"
exitcommand - this will get you back to your command line.
View Introduction to IRB on Learn.co and start learning to code for free.