The following code returns an error:
class ABC
def self.method1()
method2
end
def method2
end
end
ABC.method1
NameError: undefined local variable or method `method2' for ABC:Class
However, the code below works fine:
class ABC
def initialize
method2
end
def method2
end
end
ABC.new
Does initialize need to be used in order to properly define all methods within the class? What is wrong with the first code block?