我应该在 Dart 中始终使用 "this" 吗?
Should I always use "this" in Dart?
在方法中始终使用 'this' 是一种好习惯吗?
即使没有使用与此方法输入相同的变量名。
String getStory(number) {
return this.storyData[number];
}
这样做不会与任何输入变量名发生任何冲突(永远不会)。
预先感谢您的反馈。
一般来说,this.
只应在对使用的变量有歧义的情况下使用。
class Test{
final int x;
Test(this.x);
}
在方法中始终使用 'this' 是一种好习惯吗? 即使没有使用与此方法输入相同的变量名。
String getStory(number) {
return this.storyData[number];
}
这样做不会与任何输入变量名发生任何冲突(永远不会)。 预先感谢您的反馈。
一般来说,this.
只应在对使用的变量有歧义的情况下使用。
class Test{
final int x;
Test(this.x);
}