Ruby - Metaprogramming Fundamentals
Identify the error in this code snippet:
MyClass = Class.new do
def greet
puts 'Hello'
end
end
obj = MyClass.new
greetMyClass = Class.new do
def greet
puts 'Hello'
end
end
obj = MyClass.new
greetgreet is defined inside the class, but called without an object.greet alone outside class context causes a NameError.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions