Ruby Programming Language Features Tutorial

The following is a list of features of the Ruby Programming Language

Ruby Interaction

The Ruby official distribution also includes "irb", an interactive command-line interpreter which can be used to test code quickly. A session with this interactive program might be:

$ irb
irb(main):001:0> puts "Hello, World"
Hello, World
=> nil
irb(main):002:0> 1+2
=> 3

There also exist readline bindings (module Readline), easily allowing the user for custom shells with history support.

About the Ruby Syntax

The syntax of Ruby is broadly similar to Perl and Python. Class and method definitions are signaled by keywords. In contrast to Perl, variables are not obligatorily prefixed with a sigil. (When used, the sigil changes the semantics of scope of the variable.) The most striking difference from C and Perl is that keywords are typically used to define logical code blocks, without brackets. Line breaks are significant and taken as the end of a statement; a semicolon may be equivalently used. Indentation is not significant (unlike Python).

Gotchas and possible surprises

Although Ruby's design is guided by the principle of least surprise, naturally, some features differ from languages such as C or Perl:

In addition, some issues with the language itself are commonly raised: