When you first look at some Ruby code, it will likely remind you of other programming languages you've used. This is on purpose. Much of the syntax is familiar to users of Perl, Python, and Java (among others), so if you've used those, learning Ruby will be easy.

Language-Specific Guides

These guides cover the most important differences when coming to Ruby from:

Important Language Features and Some Gotchas

Here are some pointers and hints on major Ruby features you'll see while learning Ruby.

Iteration

Two Ruby features that are a bit unlike what you may have seen before, and which take some getting used to, are "blocks" and iterators. Instead of looping over an index (like with C, C++, or pre-1.5 Java), or looping over a list (like Perl's for (@a) {...}, or Python's for i in aList: ...), with Ruby you'll very often see:

some_list.each do |this_item|
  # We're inside the block.
  # deal with this_item.
end

Everything has a value

There's no difference between an expression and a statement. Everything has a value, even if that value is nil. This is possible:

x = 10
y = 11
z = if x < y
      true
    else
      false
    end
z # => true

Symbols are not lightweight Strings

Many Ruby newbies struggle with understanding what Symbols are, and what they can be used for.

Symbols can best be described as identities. A symbol is all about who it is, not what it is. Fire up irb and see the difference:

irb(main):001:0> :george.object_id == :george.object_id
=> true
irb(main):002:0> "george".object_id == "george".object_id
=> false