Friday, July 25, 2014

Working with irb : Interactive Ruby

Share it Please
irb stands for “Interactive Ruby.” “Interactive” means that as soon as you type something, your computer will immediately attempt to process it. Sometimes this sort of environment is called an immediate or interactive environment.

Start irb and make sure a prompt appears, like so:

irb(main):001:0>

This prompt is not as complex as it looks. All it means is that you’re in the irb program, you’re typing your first line (001), and you’re at a depth of 0. You don’t need to place any importance on the depth element at this time.
Type this after the preceding prompt and press Enter:

1 + 1

The result should come back quickly: 2. The entire process looks like this:

irb(main):001:0> 1 + 1
=> 2
irb(main):001:1>


Ruby is now ready to accept another command or expression from you.

Followers