Came across an interesting result while overriding a base class last week. Assume we have a class with two methods, one overloading the other as follows.
Assume both methods are defined within the interface (intentionally public). Now when we inherit from this class and override the first method (create:id), where does the "create:int" message in the second method get passed too? It is calling "self" from the context of the parent, but we just overrode the method in the child.
Given the above, where does the message go? Will it call create:id on the child or the parent?
Turns out, it is all in what you declare within your interface for the child. Define
in the child interface and it will pass the message to the child (using your override). Don't and the message will instead go to the parent. Thought it was very curious behavior as a C# guy.



No comments:
Post a Comment