具有以下简单类被视为静态警告,为什么?
class Vector { final int x,y; const Vector(this.x, this.y); Vector operator +(Vector v) { // Overrides + (a + b). return new Vector(x + v.x, y + v.y); } Vector operator -(Vector v) { // Overrides - (a - b). return new Vector(x - v.x, y - v.y); } Vector operator negate() { // Overrides unary negation (-a). return new Vector(-x,-y); } String toString() => '($x,$y)'; } main() { final v = new Vector(2,3); final w = new Vector(2,2); assert((-v).x == -2 && (-v).y == -3); // -v == (-2,-3) }
最佳答案
我们对此有一个未解决的错误:http://code.google.com/p/dart/issues/detail?id=3416
关于dart - 为什么覆盖否定会在Dart中引起静态警告,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12065346/