From: Josh Cheek Date: 2011-05-06T16:34:49+09:00 Subject: Re: Lets play a guessing game. (how to code this better?) --20cf307f35283c696504a296860a Content-Type: text/plain; charset=ISO-8859-1 On Fri, May 6, 2011 at 1:18 AM, Super Goat wrote: > Thanks everyone for taking the time to reply! > > The reason I had 'rand(100).to_i' and 'random.to_i' is because in IRB it > told me it was a Fixnum. Also, I had just figured out why my operators > weren't working so I wanted everything to be an integer. Obviously, in > retrospect, I see now that I didn't have to do it that way. > > In OOP, classes can inherit functionality from other classes. There are several kinds of Integers, Fixnum is one of them, Bignum is another (okay, actually, those are the only two). 1.class # => Fixnum 1.kind_of? Integer # => true Fixnum.ancestors # => [Fixnum, Integer, Numeric, Comparable, Object, Kernel, BasicObject] n = 10**1000 n.class # => Bignum n.kind_of? Integer # => true Bignum.ancestors # => [Bignum, Integer, Numeric, Comparable, Object, Kernel, BasicObject] --20cf307f35283c696504a296860a--