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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F7a303c5a1c75abbddf699280aca8408?d=identicon&s=25 James Smith (newby)
on 2014-04-02 23:56
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
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-04-06 17:18
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 topic is locked and can not be replied to.