class Test
def initialize
@var = "125"
end
def testmethod
puts @var
puts "accessing me from child class"
end
end
class TestExtension < Test
def method1
puts @var = "One Hundred and twenty five"
testmethod()
end
end
t = Test.new
p = TestExtension.new
p.method1
t.testmethod
output:
One Hundred and twenty five
One Hundred and twenty five
accessing me from child class
125
accessing me from child class
My question is that accessing the testmethod() in child class TestExtension results in accessing that value of @var which is being declared in TestExtension class instead of accessing the value which is being declared in Test class . Is it correct ?