O'Reilly logo

Ruby by Example by Kevin C. Baird

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using irb

Now that you’ve started it, irb is waiting for you to type your first line. Lines consist of one or more expressions.

Expressions

As far as Ruby is concerned, an expression is just a bit of code that has a value. In fine computer programming tradition, let’s see how irb reacts to the expression “Hello, world!”

irb(main):001:0> "Hello, world!"
=> "Hello, world!"

Note

This listing shows the line you need to type as well as how irb responds. Note also that irb shows you line numbers at the beginning of each line. I will occasionally refer to these numbers, as well.

What has happened here? You typed “Hello, world!”, and irb happily spat it right back at you. The interesting part of this is what isn’t explicit. The expression you entered has a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required