Ruby - Advanced Metaprogramming
Identify the error in the following code snippet:
module M module_eval 'def greet; puts "Hi" end' end class C include M end C.new.greet
Identify the error in the following code snippet:
module M module_eval 'def greet; puts "Hi" end' end class C include M end C.new.greet
module_eval defines method greet correctly with a semicolon separating statements.C includes M, so greet is available to instances. Calling C.new.greet prints 'Hi'.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions