Ruby - Classes and Objects
What will be the output of the following Ruby code?
class Dog
def speak
self.class
end
end
fido = Dog.new
puts fido.speakclass Dog
def speak
self.class
end
end
fido = Dog.new
puts fido.speakself is inside speakspeak, self is the instance fido.self.classclass on the instance returns its class, which is Dog.self.class in instance method = class name [OK]15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions