On Sun, 02 Sep 2007 13:19:11 +0900, 7stud -- wrote:

> Logan Capaldo wrote:
>>Try this on for size:
>> 
>> puts song.name
>> puts song.instance_variables
> 
> lol. I looked up instance_variables in "Programming Ruby (2d ed)" and it
> says:
> 
> "Note that simply defining an accessor does not create the corresponding
> instance variables."
> 
> That statement contradicts the statement I posted earlier on p. 31 of
> the same book.

For most purposes, you'll never notice the difference. There's only one 
where you will, and that's when you try to use the defined? keyword on it:

class Foo
  def foo
    @foo=nil
  end
  def bar
    defined? @foo
  end
end

a=Foo.new  => #<Foo:0xb7c58b9c>
a.bar  => nil
a.foo  => nil
a.bar  => "instance-variable"

--Ken

-- 
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/