芜湖不芜
另外我想补充一点,你可以从类的@@任何实例访问类变量()class Foo def set_name @@name = 'Nik' end def get_name @@name endenda = Foo.newa.set_namep a.get_name # => Nikb = Foo.newp b.get_name # => Nik但你不能对类实例变量(@)做同样的事情class Foo def set_name @name = 'Nik' end def get_name @name endenda = Foo.newa.set_namep a.get_name # => Nikb = Foo.newp b.get_name # => nil