On Thu, Feb 20, 2003 at 02:52:14AM +0900, ahoward wrote:
> i meant that the 's.x = 0;' statement was unnecessary! ;-)  considering ruby
> does the equivalent of
> 
> > >   bzero (&s, sizeof (s));
> 
> automatically in your stead.  eg. everything starts out as 'nil'.

This is not true.  Everything starts out as not being there at all:

  class Foo
    def initialize
      p @x                   #=> nil
      p instance_variables() #=> []
      p defined?(@x)         #=> nil

      @x = nil
      p @x                   #=> nil
      p instance_variables() #=> ["@x"]
      p defined?(@x)         #=> "instance-variable"
    end
  end

  f = Foo.new

Ruby is not initializing @x to nil here; instead, it is giving you nil
when you try to use an instance variable that doesn't exist.  Depending
on this behavior is bad style and may lead to very subtle bugs.

Paul