2008-09-23 - `The rubyist'【えぬ】の日記 - Rubyist

screenshot

一通りのメソッドは親クラスで定義、それを継承するクラスで定数のみ定義して…というのを目論んでいたんですが… class A def x p C end end class B < A C = 1000 end b = B.new b.x() -:3:in `x': uninitialized constant A::C (NameError) from -:12 コメントを書く mrkn2008/09/23 13:55http://gist.github.com/12221 n2s2008/09/23 14:51ありがとうございます。self.class.const_get :Cまたはself.class::Cてところですか。「self.class」を入れる...

http://rubyist.g.hatena.ne.jp/n2s/20080923

const_missing の実例初めてみた
親クラスから継承したメソッドで子クラスのクラス定数を使用する方法

http://b.hatena.ne.jp/entry/http://rubyist.g.hatena.ne.jp/n2s/20080923