Heredando Métodos

~/rubytesting/TheRubyProgrammingLanguage/Chapter7ClassesAndModules$ cat -n Point3D.rb 
     1  require "Point"
     2  class Point3D < Point
     3  end

~/rubytesting/TheRubyProgrammingLanguage/Chapter7ClassesAndModules$ irb
>> require "Point3D"
=> true
>> p1 = Point3D.new(1,2)
=> #<Point3D:0x10057d5e0 @y=2, @x=1>
>> p2 = Point.new(1,2)
=> #<Point:0x10056a440 @y=2, @x=1>
>> p1.class
=> Point3D
>> p2.class
=> Point
>> p1.to_s
=> "(1,2)"



Casiano Rodriguez León 2015-01-07