Take the 2-minute tour ×

I am the new one in Dart. When I create a new image element, I use:

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

Who can explain me why we have to use second syntax ? Thanks.

share|improve this question

1 Answer 1

They switched to using named arguments for readability. Looking at the first line, you can't tell which is the width and which is the height. The second one is far more readable. To read more about the change, see https://groups.google.com/a/dartlang.org/forum/?fromgroups=#!topic/misc/GW2n-l1XPh0. If you disagree with the change, see http://code.google.com/p/dart/issues/detail?id=6496.

share|improve this answer
Thanks for your help. In my option, both of them should be accepted. –  duy Dec 29 '12 at 4:14
If you are happy with my answer, perhaps you wouldn't mind accepting it. Thanks! –  Shannon -jj Behrens Dec 30 '12 at 2:24

Your Answer


