From: Mike Campbell Date: 2002-04-01T22:49:48+09:00 Subject: RE: Why isn't Math object-oriented? > 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 I'm new here, but I think the original question was not "how do I do it", but "why is it like this", which Matz answered. Still, I tend to agree with Ron; it seems unclean having a procedural set of Math operations when most things aren't. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com