3 ms·
> Subtyping, where if a type B implements the public interface of type A, values of type B can be passed as A. I am confused by this statement or it is going a
by nashashmi 2y ago
> Subtyping, where if a type B implements the public interface of type A, values of type B can be passed as A.
I am confused by this statement or it is going against what I understand.
If you have created a Type B variable, and you also have a new interface called A, and B implements A, then why would Type B variable's values be passed to A's values. 'A' is only an interface.
- mrkeen 2y agoPassed 'as' A, not passed 'to' A.
- nashashmi 2y agoThat clears it up!
- Shywim 2y agoIt says "values of type B", as in "instance of type B", can be passed as if they are "instance of type A" (which they are actually). But yes, values inside B specific to type B will not be able to be accessed when manipulating the type A.
- nashashmi 2y agoThank you. :)