Ruby - Advanced Metaprogramming
Which of the following is the correct way to define a
method_added hook inside a Ruby class?method_added hook inside a Ruby class?method_added hook is an instance method of the class's singleton class, so it should be defined as an instance method inside the class (not a class method). It receives the method name as a symbol.def method_added(method_name) which is correct. def self.method_added(method_name); puts "Added: #{method_name}"; end defines it as a class method (self.method_added), which is incorrect. Options B and C miss the required parameter.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions