[ next ] [ prev ] [ contents ] [ up to Ruby Immersion ] Using Ruby

Gotchas for Java Programmers

  • No Primitives, Integers and floats are objects!
    • -1.abs => 1

  • No Semi-colons

  • nil, not null

  • nil is an object!
    • nil.nil? => true

  • nil and false are false
    • everything else, including 0, is true

  • Picky about spaces
    • f (arg) gives warning.
    • f(arg) is ok.

  • Message Based vs Function Based Polymorphism (more)

  • Different type model

  • Expression oriented syntax.
    • Almost everything returns a value
    • x = if a==0 then 5 else 1 end
    • Methods automatically return their last expression.

  • Single Inheritance
    • But mixins are available

  • Classes are always open (even built in classes)

Note: Some of these "gotchas" are good!.


[ next ] [ prev ] [ contents ] [ up to Ruby Immersion ] Copyright 2003 by Jim Weirich.
Some Rights Reserved