ImageElement的构造函数

时间:2012-12-29 02:11:55

标签: constructor dart

我是达特的新人。当我创建一个新的图像元素时,我使用:

ImageElement elem = new ImageElement("src",10,10); //comlier error, extra-argument.
ImageElement elem = new ImageElement(src:"src",width:10,height:10); //OK.

谁能解释我为什么要使用第二种语法?

1 个答案:

答案 0 :(得分:2)

为了便于阅读,他们转而使用命名参数。看第一行,你无法分辨哪个是宽度,哪个是高度。第二个更具可读性。要详细了解更改,请参阅https://groups.google.com/a/dartlang.org/forum/?fromgroups=#!topic/misc/GW2n-l1XPh0。如果您不同意更改,请参阅http://code.google.com/p/dart/issues/detail?id=6496

相关问题