1
Hello, everybody.
class Automovel
def self.tipo_cambio
puts "Manual"
end
def acelera
verifica_combustivel()
# Injetando combustível
puts "Acelerando automóvel"
freia()
end
private
def verifica_combustivel
puts "verificando combustível!!!"
end
end
#-----------
class Carro < Automovel
def freia
puts "freiando"
#acelera()
verifica_combustivel()
end
end
I’ve been studying Ruby, and in making this code I came across a question.
When creating an instance of the Automovel class in the terminal (alias car = Car.new) he usually reads the method accelerates of Automovel giving the command car. (returns "injecting fuel" etc.), but when calling the brake method of the Car class by car.freia, it returns the check method. I want to understand why it returns normally if the method is private and can be accessed only by the Automovel class?