Ruby - Advanced Metaprogramming
Find the problem in this code snippet:
module M
module_eval do
def greet
'Hello'
end
end
end
M.greetFind the problem in this code snippet:
module M
module_eval do
def greet
'Hello'
end
end
end
M.greetThe method greet is defined as an instance method inside the module.
Calling M.greet tries to call a module method, but greet is not a module method, causing NoMethodError.
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions