🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
当定义类之间的合一行为,重要的是要记住合一是方向性的:我们可以分配一个更特别的类(例如一个子类)到一个通用类型(例如一个父类),但是反过来是不允许的。 > When defining unification behavior between classes,it is important to remember that unification is directional: We can assign a more specialized class (e.g. a child class) to a generic class (e.g. a parent class) but the reverse is not valid. 如下的赋值是允许的: * 子类分配到父类 * 类分配到实现接口 * 接口到基础接口 > The following assignments are allowed: > * child class to parent class > * class to implementing interface > * interface to base interface 这些规则是可传递的,意味着一个子类也可以被分配到它的基础类的基础类,它的基础类实现的一个接口,实现类的基础接口等等。 > These rules are transitive, meaning that a child class can also be assigned to the base class of its base class,an interface its base class implements,the base interface of an implementing interface and so on.