T
Tom Allison
Hello,
I'm really new to Ruby and rather new to OOP in general. I've been
using Perl for about 7 years now and have a fairly good understanding of
that language. I've never really entertained Python to any serious
degree beyond 'Hello World'. Now you know my background.
I tried to do the following:
13.lcd 3
and it failed in the irb.
Why?
My thinking is that 13 is a Fixnum class and Fixnum inherits Integer.
Integer has a method 'lcd' that returns the least common denominator.
Since Fixnum < Integer then all the methods of Integer should be
available to all the child objects (Fixnum and super). And if this is
true, then calling a method like I did (Fixnum#lcd) implies an
inheritance search to find that class.
But my thinking seems to not reflect Ruby very well.
Can someone please tell me what I did wrong in the code and also in
thought? It's little niggly bits like this that get frustrating.
I'm really new to Ruby and rather new to OOP in general. I've been
using Perl for about 7 years now and have a fairly good understanding of
that language. I've never really entertained Python to any serious
degree beyond 'Hello World'. Now you know my background.
I tried to do the following:
13.lcd 3
and it failed in the irb.
Why?
My thinking is that 13 is a Fixnum class and Fixnum inherits Integer.
Integer has a method 'lcd' that returns the least common denominator.
Since Fixnum < Integer then all the methods of Integer should be
available to all the child objects (Fixnum and super). And if this is
true, then calling a method like I did (Fixnum#lcd) implies an
inheritance search to find that class.
But my thinking seems to not reflect Ruby very well.
Can someone please tell me what I did wrong in the code and also in
thought? It's little niggly bits like this that get frustrating.