I have an existing class Foo, and existing objects of that class.

I now extend the class by adding a method, which makes use of an instance
variable which previously did not exist.

How can I make it test that the instance variable is uninitialised, so I can
prevent a warning? This is what I am trying to do:

  class Foo
    attr_reader :things
    def add_thing(n)
      if @things.nil?
        @things = [] 
      end
      @things << n
    end
  end

However, the test '@things.nil?' generates
'warning: instance variable @things not initialized'
if ruby is running with -w. (This is 1.6.8)

I am hoping that I don't have to keep track of all existing Foo objects,
just so that I can send them a message 'reset_things'

Thanks...

Brian.