I am new to Ruby. I have a question regarding the use of Inheritence in Ruby.
I have a class called Doggy inside a Doggy.rb file
class Doggy def bark puts "Vicky is barking" end end
I wrote another class called Puppy in another file called puppy.rb
class Puppy < Doggy end puts Doggy.new.bark
I get this error:
Puppy.rb:1:in `<main>': uninitialized constant Doggy (NameError)
Is it mandatory to use these classes (Doggy and Puppy) in only one file?
Edited by
As suggested, I tried using require and require_relative as shown, but still I get below Error
Puppy.rb:1:in `<main>': uninitialized constant Doggy (NameError) class Puppy < Doggy end require_relative 'Doggy.rb' puts Doggy.new.bark
source share