From: Eero Saynatkari Date: 2005-12-30T08:42:51+09:00 Subject: Re: What is the difference between :foo and "foo" ? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2005.12.30 08:35, Steve Litt wrote: > On Thursday 29 December 2005 01:03 pm, James Edward Gray II wrote: > [clip] > > > class variable @wilbur, > > > > That's an instance variable, not a class variable. > > I knew that :-) Skipping from Perl to C to C++ to Python to Ruby, I sometimes > forget the terminology. > > > > As Austin taught us yesterday, it doesn't make the variable either, > > just some methods. > > My understanding of Ruby is the getters and setters it makes make the > variable, because the setter sets @wilber to its argument. The instance variable is not created by the attr_* statement, however. Only if you call obj.attribute = something will it be created (unless you create it in #initialize or something). irb(main):001:0> class Foo irb(main):002:1> attr_accessor 'bar' irb(main):003:1> end => nil irb(main):004:0> f = Foo.new => # irb(main):005:0> f.inspect => "#" irb(main):006:0> f.bar = 5 => 5 irb(main):007:0> f.inspect => "#" # <-- This here irb(main):008:0> > SteveT E -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFDtH2ZxvA1l6h+MUMRAudYAKCRQTHp/6p70j83waz8y3r56i4mwACeNkAW 5rX3d6mtf9XMuGZlu+zyk/U= =ogE8 -----END PGP SIGNATURE-----