Methods from C Pine book -- need some help understanding the basic concepts

Newbie question. I’m using C Pine’s great book on Intro to Programming
with Ruby and am stuck on the code in ch8 and I do not get it at all…
the code and my comments or where I get stuck are here:
http://codepad.org/rjhEy2eg

In Ruby, any standard mathematics involving two Integers will result an
an Integer unless you specifically alter one of the operands to a Float
(or something else).

It works because according to those rules:

3 / 10 = 0

3.0 / 10 = 0.3

3.to_f / 10 = 0.3

So in the operations performed, he’s relying on the way Integers (Fixnum
Class) behave.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs