Ruby - Class Methods and Variables
What will be the output of this Ruby code?
class Dog
def self.bark
"Woof!"
end
end
puts Dog.barkclass Dog
def self.bark
"Woof!"
end
end
puts Dog.barkbark is defined as a class method using self.bark and returns the string "Woof!".puts Dog.barkDog.bark returns "Woof!", which puts prints to the console.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions