Ruby Programming/Notation conventions

Command-line examples
In this tutorial, examples that involve running programs on the command-line will use the dollar sign to denote the shell prompt. The part of the example that you type will appear bold. Since the dollar sign denotes your shell prompt, you should not type it in.

For example, to check what version of Ruby is on your system, run:

$ ruby -v

Again, do not type the dollar sign – you should only enter " " (without the quotes). Windows users are probably more familiar seeing " " to denote the shell prompt (called the command prompt on Windows).

An example might also show the output of the program.

$ ruby -v ruby 1.8.5 (2006-08-25) [i386-freebsd4.10]

In the above example, " " is printed out after you run " ". Your actual output when you run " " will vary depending on the version of Ruby installed and what operating system you are using.

Running Ruby scripts
For simplicity, the following convention is used to show a Ruby script being run from the shell prompt.

$ hello-world.rb Hello world

However, the actual syntax that you will use to run your Ruby scripts will vary depending on your operating system and how it is setup. Please read through the Executable Ruby scripts section of the ../Hello world/ page to determine the best way to run Ruby scripts on your system.

Running irb
Ruby typically installs with "interactive ruby" (irb) installed along with it. This is a REPL that allows you to experiment with Ruby, for example:

$ irb >> 3 + 4 => 7 >> 'abc' => "abc"