I’ve got a question about using alias_method with a class and a module.
The module gets included by the class. But I can’t figure out how to
deal with the initialize method.
Why isn’t tests[1] filled? I tried instance_eval and stuff but I don’t
exactly understand what I’m supposed to do…
I could be wrong (of course!), but it looks to me like the aliasing
isn’t working the way you think it should. Rather than
initialize_with_extras being triggered and then triggering Test’s
initialize, only Test’s initialize is being hit. Hrm. What happens if
you call initialize_with_extras just initialize and create a conflict?
Or maybe something like this?
Why isn’t tests[1] filled? I tried instance_eval and stuff but I don’t
exactly understand what I’m supposed to do…
I do not understand what you are trying to achieve. Anyway, tests[1] is
“ok”. Arrays are zero based, the counting starts at zero.
ar=[“a”,“b”]
p ar[0]
I’ve got a question about using alias_method with a class and a module.
The module gets included by the class. But I can’t figure out how to
deal with the initialize method.
I think this is because the class has “overwritten” the initialize
method from the module (sort of how a child class will do regarding
its parent). Hrm hrm hrm. basically, when you call test.new it goes to
the Test class and says, “Okay. Do i have an initialize method here?
Ah! Yes. Here it is.” And runs it. If it didn’t find one, it would
kick up to the module’s initialize method, or if the initialize method
for the class called on the module’s… Remember that the chain
looking for methods trickles UP the inheritence chain and that
including modules is a similar chain.
Sorry I don’t have another suggestion, but maybe that’ll point you in
the right direction?