Control statements are functional in Ruby: type_person = case number when 13 'Superstitious' when 42 'Sci-fi fan' end % As with Perl, always turn on warnings mode (ruby -w or export RUBYOPT="-w") % In the notation of Class#method, the hash mark is not the actual syntax used, but respresents 'instance method'. For String#gsub, the actual call would in fact be something like 'foo'.gsub(...) % In case statements, the === message is passed to do more flexible matching. This is how matching of ranges and regexes works automagically. case foo when /bar/ ... # /bar/ === foo when /baz/ ... # /baz/ === foo end % You can apparently get away with defining variables in statement modifiers, unlike with 'my' lexical vars in Perl: foo = 42 if bar == 69 % Remember, Ruby is pass by reference! foo = 'bar' def baz(qux) qux[2] = 'z' end puts foo # => "baz" To solve this, use the 'dup' method for mutable arguments (e.g., arrays, hashes). % Ruby confers Smalltalk-like semantics on a few fundamental data types: true - Boolean true value false - Boolean false value nil - undefined or don't know nil will technically evaluate to a false value in an if statement, for instance, but in general, you should use false when you /mean/ false. % Variable scope is a little unusual; locals fall either within the scope of the top level, class or module definition, or method. In methods, one cannot access the surrounding scope (global variables are always available, but those are mostly for asshats), but blocks certainly can. Caveat! i = 0 (0..2).each do |i| puts "inside block: i = #{i}" end puts "outside block: i = #{i}" # -> 'outside block: i = 2' % The implicit invocant of methods is self. If Ruby ever gives any suggestion of being partly procedural, it's an illusion (although sometimes a useful illusion); self is actually an instance of Object, which mixes in Kernel. Method definitions at the toplevel are implicitly subsumed by the class Object. % A method may accept array or hash arguments with * and **, as in Python: def pass_through(*args) args.collect { |x| x } end pass_through(%w(foo bar baz)) When the asterisk is used in a method call, the elements of the referent array are applied to the method x = %w(foo bar baz) def qux(eenie, meenie, meinie) ... end qux(*x) But that's not all! The asterisk can also be used in the lvalue of a variable assignment, c.f. Perl: my ($foo, @bar) = qw/foo bar baz/; foo, *bar = %w(foo bar baz); % :attr_reader :symbol, :list allows instance variables to be 'read' with methods of the same name % string << 'more' is faster than string += 'more', because the latter actually creates a new object, whereas << is destructive. % You can enable Readline completion in irb with require 'irb/completion'. Enough said, use it. % When you say 'foo'.methods in irb to inspect available facilities, there will always be a number of (usually) extraneous methods defined in the Kernel module. To narrow the list down to those operators relevant to the class and its immediate superclasses, do: 'foo'.methods - Kernel.methods Note that this only works well if the invocant of the first methods call is an instance of some class: irb(main):012:0> 'foo'.methods - Kernel.methods => ["%", "index", "<<", "oct", "slice", "length", "upcase", "partition", "squeeze", "upcase!", "crypt", "delete!", "to_sym", "*", "grep", "lstrip!", "+", "center", "rindex", "between?", "reject", "size", "strip", "count", "succ!", "downcase", "squeeze!", "downcase!", "intern", "member?", "next", "find", "each_with_index", "rstrip!", "each_line", "to_i", "slice!", "replace", "collect", "tr", "reverse", "all?", "entries", "unpack", "lstrip", "capitalize", "capitalize!", "detect", "zip", "each_byte", "to_f", "casecmp", "map", "tr_s", "empty?", "to_str", "any?", "tr!", "rstrip", "match", "sort", "next!", "swapcase", "min", "swapcase!", "ljust", "upto", "find_all", "sum", "hex", "each", "insert", "reverse!", "dump", "inject", "delete", "concat", "tr_s!", "succ", "sort_by", "max", "[]", "strip!", "rjust", "[]="] irb(main):013:0> String.methods - Kernel.methods => ["superclass", "allocate", "new"] % 'abcd'[0] returns the Fixnum value of the chracter 'a', 97. 'abcd'[0,1] gives you what you want. (That's weak...)