Using an interactive shell (REPL)

Ruby:
Using an interactive shell (REPL)

How to:

Ruby’s REPL is called IRB (Interactive Ruby). Jump in and try Ruby straight from your terminal:

irb
2.7.0 :001 > puts "Hello, Ruby world!"
Hello, Ruby world!
 => nil
2.7.0 :002 > 5.times { print "Ruby! " }
Ruby! Ruby! Ruby! Ruby! Ruby!  => 5

Deep Dive

Introduced in Ruby 1.8, IRB is a staple for Rubyists. It’s inspired by the interactive shells of Lisp and Python, melding experimentation with immediate feedback. Alternatives like Pry offer more features like syntax highlighting and a more robust debugging environment. IRB itself is simple but can be augmented with gems like ‘irbtools’ to extend functionality. How IRB handles the read-eval-print loop is by reading each line of input, evaluating it as Ruby code, and then printing the result, looping this process until exit.

See Also