I am trying to run this code and it gives different output with different versions of ruby 2.5 - 2.7
code:
class ParentClass
def the_public_method
self.method1
end
private
def method1
puts "The private has been called"
end
end
class ChildClass < ParentClass
def test
self.method1
end
end
ParentClass.new.the_public_method
ChildClass.new.test
on ruby 2.5 it gives:
Traceback (most recent call last):
1: from main.rb:19:in `<main>'
main.rb:3:in `the_public_method': private method `method1' called for
#<ParentClass:0x000056367ee0b388> (NoMethodError)
Did you mean? method
methods
exit status 1
on ruby 2.7 it gives:
The private has been called
The private has been called
I think the first output is correct with the older version of ruby.. any feedback?