If the class Name were in a different file, you would just require that file first : inheritance « Class « Ruby






If the class Name were in a different file, you would just require that file first


class Name
  attr_accessor :given_name, :family_name
end
////////////////

File: address.rb

#!/usr/bin/env ruby

require 'name'

class Address < Name

  attr_accessor :street, :city, :state, :country

end

a = Address.new
puts a.respond_to?(:given_name)

 








Related examples in the same category

1.Basing one class on another is called inheritance.
2.Extends class
3.how inheritance works in code form
4.Basing One Class on Another: a Demo
5.different types of people
6.Structuring Your Pets Logically
7.Add new constructor
8.Module and class hierarchy
9.Subclass Array class