Python 可以通过装饰器 @property
像属性一样访问方法。 Dart 有这样的东西吗?
class Test():
@property
def example():
return "This isn't really a property"
a = new Test()
print a.example
最佳答案
getters的概念看起来很相似:
class Test {
String get example {
return "This isn't really a property";
}
}
main() {
var a = new Test();
print(a.example);
}
关于dart - Dart 中的 Python @property 等价物?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17427431/