Ruby - Advanced Metaprogramming
Which of the following is the correct way to define an
inherited hook in a Ruby class?inherited hook in a Ruby class?inherited hook must be defined as a class method, so it needs self.inherited and takes one argument: the subclass.def self.inherited(subclass); puts "New subclass created"; end correctly defines the class method with the subclass parameter. Incorrect versions lack self. (instance method), omit the subclass parameter, or use wrong parameters like self.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions