【发布时间】:2013-08-25 11:59:31
【问题描述】:
假设我有一个有很多实例变量的类。我想重载 == 运算符(和 hashCode),以便可以将实例用作映射中的键。
class Foo {
int a;
int b;
SomeClass c;
SomeOtherClass d;
// etc.
bool operator==(Foo other) {
// Long calculation involving a, b, c, d etc.
}
}
比较计算可能很昂贵,所以我想在进行计算之前检查other 是否与this 相同。
如何调用 Object 类提供的 == 运算符来执行此操作?
【问题讨论】:
标签: dart