leroydupuis
Joined
50 Experience
0 Lessons Completed
0 Questions Solved
Activity
Posted in Inheritance is not working.
Hi,
I'm a starter in ruby, I have a doubt in Inheritance in ruby. This is my sample code.
class TimeLine
attr_reader :tweets
def initialize(tweets=[])
@tweets = tweets
end
def print
puts tweets.join("\n")
end
end
class AuthenticateTimeLine < TimeLine
def print
authenticate!
super
end
def authenticate!
puts "authenticated!"
end
end
TimeLine.new([1,2,3,4])
authenticate_timeline = AuthenticateTimeLine.new
authenticate_timeline.print
In my code I'm getting a empty array when calling from the child class.Why is that happening?