Ruby - Classes and Objects
What will this Ruby code print?
class Cat
def initialize(name)
@name = name
end
def name
@name
end
end
cat = Cat.new("Whiskers")
puts cat.name
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions