3

Python では、decorator を使用してプロパティのようにメソッドにアクセスできる可能性があります@property。ダートにこんなのありますか?

class Test():
    @property
    def example():
        return "This isn't really a property"

a = new Test()
print a.example
4

1 に答える 1

4

ゲッターの概念は似ています:

class Test {
  String get example {
    return "This isn't really a property";
  }
}

main() {
  var a = new Test();
  print(a.example);
}
于 2013-07-02T14:01:12.737 に答える