2009-06-25から1日間の記事一覧
モジュールで定義されていない定数を参照したとき、Module#const_missingが実行されます。 module A AAA = "AAA" def self.const_missing(id) return "BBB" if id == :BBB raise "not found." end end puts A::AAA puts A::BBB 実行結果です。 AAAは定数とし…
モジュールで定義されていない定数を参照したとき、Module#const_missingが実行されます。 module A AAA = "AAA" def self.const_missing(id) return "BBB" if id == :BBB raise "not found." end end puts A::AAA puts A::BBB 実行結果です。 AAAは定数とし…