On Dec 28, 2007 10:37 AM, Paul Brannan <pbrannan / atdesk.com> wrote:
> On Sat, Dec 29, 2007 at 12:32:10AM +0900, Rick DeNatale wrote:
> > but what about this:
> >
> > def divide(a, b)
> >    use namespace Mathn
> >    a / b
> >  end
> >
> > Now, I'd think you would want:
> >
> > 1 / 2 #=> 1
> >
> > divide(1,2) #=> 1 / 2
> >
> > The problem here it seems that you would need more than attach a
> > namespace to an object.  Here we want the Integer/Fixnum classes to
> > act differently in the context of executing the divide method, even
> > for objects instantiated outside and passed in.
>
> I'm having trouble understanding why this case wouldn't work as
> expected.  Can you elaborate?

What causes the integer 1 to use the '/' method monkeypatched in Mathn
in one case and not the other?

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/