Let’s see what happens if we change a module after it has been included.
As we can see the result is “Mike Bohanan”. Do not think of including a module as including all the code of module into the class. This is not like all the code in module is copy pasted in the class. Including a module does not work like that.
Including a module is more like setting up a link in the method lookup.
p1 is looking for method
name then first ruby will check if class
has any instance method called
Answer is No.
Then Ruby will check if class
Person includes any modules.
Answer is Yes. Module
Info is include.
Then Ruby checks if that module has a method called
Answer is yes.
Ruby executes that method.
That is why we can make changes to the module even after they are included in a class and the updated method will be picked up.