From: nobu.nokada@... Date: 2002-04-01T22:29:17+09:00 Subject: Re: Why isn't Math object-oriented? Hi, At Mon, 1 Apr 2002 21:49:58 +0900, Ron Jeffries wrote: > I'm OK with sin(x) working. I'm not OK with not being able to say > > r*theta.sin + r*theta.cos > > because that's how every other similar operation would be expressed in Ruby. > > I needed to do one of these things recently. When I said 4.sqrt and it didn't > work, I was /very/ surprised. > > The two ways are not incompatible, as far as I can see. It's easy. (Math.methods - Module.methods).each do |m| Numeric.class_eval "def #{m}(*a) Math.#{m}(self, *a) end" end -- Nobu Nakada