class a {/*code*/}
class b extends a {/*more code*/}
void main() {
b c = new b();
print(c.runtimeType == a); //type == inheritedType
//or
print(c.runtimeType inherits a); //operator for inheritance
//or
print(c inherits a); //other operator for inheritance
}
Run Code Online (Sandbox Code Playgroud)
你能用type == inheriting type, type inherits other type, 或instance inherits other type or type吗?有没有办法做这样的事情?因为我还没有找到任何方法。
使用is.
你可以做到c is a。请注意,new a() is a也是true如此。如果你真的想知道一个实例是否是另一种类型的子类型,你可能会问c is a && c.runtimeType != a.
| 归档时间: |
|
| 查看次数: |
1594 次 |
| 最近记录: |