This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Incorrect optional parameter argument removal "?" #28
Closed
Description
@pavelgj In block.dart attrAccessorFactory the optional argument operator "?" removal was done incorrectly in #23 since one cannot distinguish "explicitly passed null" from "did not pass an optional argument" parameter. :
attrAccessorFactory(dom.Element element, String name) {
return ([String value]) {
if (value != null) {
if (value == null) { // THIS CODE IS NOW DEAD
element.removeAttribute(name);
} else {
element.setAttribute(name, value);
}
return value;
} else {
return element.getAttribute(name);
}
};
}
In a Google+ thread I saw this suggestion for handling similar problem with a special default value:
class Nothing() { const Nothing(); }
class List {
List([n = const Nothing()]) { if(identical(n, const Nothing()) { ... } else { ... } }
}
Metadata
Metadata
Assignees
Labels
No labels