Useful Code/Commands

IRB

  1. irb --readline -r irb/completion

    When you press Tab, Irb will attempt code completion. If there are several possible matches press Tab twice and Ruby will give you a complete list of them. This works for jirb in JRuby but with some slight differences.

JRuby/Swing

  1. lab = JLabel.new lab.opaque = true lab.background = Color::CYAN

    If you want to give a label a background colour, set the opaque property to true and then apply the colour.

Miscellaneous

  1. ARGV.clear

    Clears out the command line argument array.

  2. string = <<-STRING_END ... STRING_END

    Here documents begin with << or <<- followed by a constant which is the string terminator. If the document begins with << then the terminator must be in the left-most column.