【发布时间】:2021-02-15 21:14:33
【问题描述】:
我知道如何使用关键字 this,但我不确定是否存在出于某些原因必须避免使用它的情况。来自dart.dev, chapter constructors的示例:
class Point {
double x, y;
Point(this.x, this.y);
// Named constructor
Point.origin() {
x = 0;
y = 0;
}
}
他们为什么不写
this.x = 0;
而不是
x = 0;
?
【问题讨论】: