class Point extends Test {
num x;
num y;
num z;
num get a {
return this.x + this.y;
}
set a(num v) {
x = v - y;
}
Point.fromJson(Map jsonMap)
: this.x = jsonMap['x'],
y = jsonMap['y'],
super.fromJson({}) {
print(this.x);
print('In Point.fromJson(): ($x, $y, $z)');
}
Point.aliasB(Map jsonMap, num z)
: this.z = z,
super.fromJson({}) {
Point.fromJson(jsonMap);
}
Point(Map jsonMap, this.z) : super(jsonMap) {
print('In Point(): ($x, $y, $z)');
x = jsonMap['x'];
y = jsonMap['y'];
print('In Point(): ($x, $y, $z)');
}
}
class Test {
num x;
num y;
Test(Map map)
: x = map['x'],
y = map['y'] {
print('In Parent.Test(): ($x, $y)');
}
Test.fromJson(Map map) : this(map);
}
main(List<String> args) {
new Point({'x': 1, 'y': 2}, 3);
new Test({'x': 1, 'y': 2});
}
In Parent.Test(): (null, null)
In Point(): (null, null, 3)
In Point(): (1, 2, 3)
In Parent.Test(): (1, 2)
希望有大佬能解答一下菜鸟的疑问
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.