From: Rich Kilmer Date: 2002-09-10T13:14:16+09:00 Subject: RE: Larry Wall's comments on Ruby class Numeric Math.singleton_methods.each do | meth | module_eval <<-EOF def #{meth} Math.#{meth}(self) end EOF end end 10 lines...but works with all methods defined in Math (some new ones added in 1.7). -rich > -----Original Message----- > From: Hal E. Fulton [mailto:hal9000@hypermetrics.com] > Sent: Monday, September 09, 2002 11:57 PM > To: ruby-talk ML > Subject: Re: Larry Wall's comments on Ruby > > > ----- Original Message ----- > From: "Reimer Behrends" > Newsgroups: comp.lang.ruby > To: "ruby-talk ML" > Sent: Monday, September 09, 2002 10:53 PM > Subject: Re: Larry Wall's comments on Ruby > > > > Hal E. Fulton (hal9000@hypermetrics.com) wrote: > > [...] > > > It should be possible to write a little module to mix > > > in methods into Numeric (I suppose) which would do the > same thing. > > > > class Numeric > > [:sin, :cos, :tan, :log, :log10, :exp, :sqrt].each do > > | meth | > > module_eval <<-EOF > > def #{meth} > > Math.#{meth}(self) > > end > > EOF > > end > > end > > > > Personally, I still prefer the traditional function notation. > > Yeah... what he said. :) > > Hmm, ten lines exactly. > > Thanks... > > Hal > > >