Newbie question: 9/5=1?

> Technically, it looks like you can call 'div', i.e. 9.div(5) will still
> return the standard integer division result. But this is completely
> non-obviously, and I only learned it after digging in the source code.

That works on Ruby 1.8 but not 1.6, which means I need to check the
version and if I'm using Ruby 1.6, I need to define Integer#div myself
using Integer#/. IMO, this is silly. I just hate it when people go
around messing with Ruby's built-in classes with no good reason. It's
very difficult to code around that sort of code.

Yeah, I didn't even think to check the Ruby 1.6 sources. But the point is
moot; I completely agree with you that it's dangerous and "POLS-violating"
for modules to override the expected behavior for such fundamental concepts
as integer division.

BTW, your reply was to me and not to the ML (I wasn't sure if that was
intentional or not).

I replied to you and the newsgroup (comp.lang.ruby) at the same time. That
response may not have been mirrored over to the ML yet.

ยทยทยท

On Mon, 24 Mar 2003 10:59:22 -0500, Paul Brannan <pbrannan@atdesk.com> wrote :

On Mon, Mar 24, 2003 at 10:01:31AM -0600, Lyle Johnson wrote: