class Test
def initialize
puts 'initializing test'
end
end
class TestB < Test
end
something = Class.new(Test)
In the above, the superclass initialize method is not called. If I do
something = TestB.new
it is called.
Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Reading the documentation, Class.new(Test) yields a derived class object which has Test as its superclass.
You need to call new on that result to get the printout.