假设您在数组中有(任何数量)值,并且您想查看它们中的任何一个是否超过(较低数量)和较低数量,您会怎么做?
无需执行 for 循环或任何冗长的代码即可回答。
也许是这样的:
var havingParty = false;
if ((theArrayWithValuesIn > 10) && (theArrayWithValuesIn < 100)) {
havingParty = true;
} else {
havingParty = false;
}
Run Code Online (Sandbox Code Playgroud)
会工作。
请注意:x和y,碰撞检测,紧凑代码。
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吗?有没有办法做这样的事情?因为我还没有找到任何方法。