From: raymond medeiros Date: 2005-09-24T17:18:44+09:00 Subject: Re: OpenClass ------=_Part_1008_26623681.1127549921982 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline me either, that was sort of my point hindsight being 20/20, seemed like the thing to do at the time. althought i'd be interested in hearing more about what transfire is talking about perhaps there is more to it than i'm seeing= . ruby is so insanely dynamic that it seems reasonable to do insane things fo= r no apparent reason. www.whytheluckystiff.net is an excellent example of totaly complete insanity and randomness. viva la ruby! On 9/24/05, Robert Klemme wrote: > > raymond medeiros wrote: > > it seemed like a good idea at the time but honestly, hindsight being > > 20/20 i have no idea what i'd do with this: > > > > class OpenClass > > #create the new method > > def add_member(name, new_proc) > > self.instance_eval %{ > > def #{name} > > #{new_proc} > > end > > } > > end > > > > #there are no predefined methods so we'll add them dynamically > > def method_missing(method, *args) > > new_proc =3D args[0] > > mname =3D method.to_s.gsub(/=3D/, "") > > add_member(mname, new_proc) > > end > > end > > > > o =3D OpenClass.new > > o.test_method =3D %{ puts "test_method" } > > I don't see the advantange of this syntax over > > def o.test_method() puts "test_method" end > > Can you explain? > > Kind regards > > robert > > > -- 2.times { p true } ------=_Part_1008_26623681.1127549921982--