Markus Fischer wrote:
> You haven't defined an explicit constructor (source wise). Java creates
> implicit ones, I'm not sure about ruby. Let Brian answer that :)

There is an implicit constructor: it calls 'allocate' to create the 
object, and then 'initialize' to fill in its instance variables. The 
default initialize, inherited from Object, does nothing.

Examples:

  class Foo
  end
  f = Foo.new
  puts f.inspect  # f has no instance variables

  class Foo
    def initialize
      @iv = 123
    end
  end
  g = Foo.new
  puts g.inspect  # g has one instance variable

  class Foo
    def initialize(val = 123)
      @iv = val
    end
  end
  h = Foo.new      # has @iv=123
  i = Foo.new(456) # has @iv=456

Note how we can modify the class even after we've created existing 
objects from it :-)

A good starting point for self-study is:
http://www.ruby-doc.org/docs/ProgrammingRuby/

HTH,

Brian.
-- 
Posted via http://www.ruby-forum.com/.