Friday, September 23, 2011


Constants are capitalised
Symbols are prefixed with a colon and are lightweight strings

Question marks and exclamation marks can be used in method names

Class methods are invoked with double colon '::' instead of a '.'

Global variables begin with '$'

Instance variables begin with '@'  ("attribute")
Class variables begin with '@@'  ("attribute all")

Code blocks can be surrounded with either {} or do-end
Block variables are surrounded by | and separated by commas.  E.g.
{ |x,y| x + y }

Range.  E.g. (1..3)  ('a'..'z')

Hashes: {'a' => 'aardvark', 'b' => 'badger'}

Regexp: /ruby/, /[0-9]+/ and /^\d{3}-\d{3}-\d{4}/