タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

Rubyとmetaに関するihagのブックマーク (1)

  • yohasebe.com : Ruby の動的オブジェクト生成について

    class Test puts "1. 基底クラス内、全てのメソッドの外側。" + "object ID は #{self.object_id}" def meth puts "9. 基底クラスのインスタンスメソッド内。" + "object ID は #{self.object_id}" end class << self puts "2. 基底クラスの特異クラス内。" + "object ID は #{self.object_id}" def meth2 puts "4. 基底クラスのクラスメソッド内。" + "object ID は #{self.object_id}" sing = class << self; self; end; puts "5. sing は特異メソッドを参照。" + "object ID は #{sing.object_id}" end end end cl

    ihag
    ihag 2010/04/29
  • 1