From: Josh Cheek <josh.cheek / gmail.com>
Subject: Re: 'def', but with a closure
Date: Mon, 15 Feb 2010 15:35:44 +0900
Message-ID: <4a2cfc231002142235k39a6aa2coaf956300dc3555d7 / mail.gmail.com>
> way to work. Hidetoshi's solution works because of TkLabel's behaviour, but
> can't be expected to work for any object (ie not generalizable).

e.g.
------------------------------------------------------
objs = @cars.collect{|owner, model|
  obj = Object.new
  obj.instance_eval{
    @owner = owner
    @model = model
    def get_model
      @model
    end
    def get_owner
      @owner
    end
  }
  obj
}

objs.each{|o| p [o.get_model, o.get_owner]}
------------------------------------------------------
-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)