From: keiju@... (=?ISO-2022-JP?B?GyRCQFBETTc9PHkbKEI=?= ) Date: 1997-08-28T22:14:02+09:00 Subject: [ruby-list:3912] Re: class variable けいじゅ@日本ラショナルソフトウェアです. In [ruby-list :03911 ] the message: "[ruby-list:3911] Re: class variable ", on Aug/28 21:25(JST) shugo@po.aianet.ne.jp (前田 修吾/ maeda shugo) writes: >前田です。 > >In message "[ruby-list:3902] Re: class variable" >Yukihiro Matsumoto wrote: > >||[その1] >|| クラス変数はないのですか。 >class << Foo > attr :foo, TRUE >end > >っていう手もありますね。 うーん. なかなか素晴らしい... と思いましたが... (中略) >とすれば期待どおりの動作になるのではないでしょうか? クラス階層がある時には, クラス定数の場合と動作がことなってしまいます. class Foo FooV = "foo" end class Bar < Foo print FooV end は, 確かに "foo" となりますが, class Foo class << Foo attr :foo, TRUE end self.foo="foo" end class Bar < Foo print self.foo end はちゃんと動作しません. FooとBarは別のオブジェクトなので, インスタンス 変数は共有しないんですね. __ ................................石塚 圭樹@日本ラショナルソフトェア... ----------------------------------->> e-mail: keiju@bc.mbn.or.jp <<---