Open jamesderlin opened 3 years ago
Good point. The behavior is equivalent only to the default behavior of []=
. The documentation should be rewritten.
I realize now that I probably should have started from MapMixin
instead, which has the behavior I expected. I get the ...Mixin
and Delegating...
classes mixed up. (Actually, I'm not sure that I was even aware until now that there were two sets of classes.)
I'll also note that the documentation for ListMixin
mentions DelegatingList
, but the DelegatingList
documentation does not refer to ListMixin
. Meanwhile there are no references in either direction for MapMixin
/DelegatingMap
nor for SetMixin
/DelegatingSet
. It'd be nice if each referenced the other and explained what the differences are.
The documentation for
DelegatingMap.addAll
states:That led me to mistakenly believe that a class that derives from
DelegatingMap
could overrideoperator []=
and change the behavior ofaddAll
(andaddEntries
, etc.) for free. Alas, no, dartdoc automatically copied that from the baseMap.addAll
documentation, andaddAll
simply callsaddAll
on the delegate. (This behavior makesDelegatingMap
seem significantly less useful.)The implementation shown in the
DelegatingMap.addAll
documentation also doesn't make this as obvious as it could be because the delegate is named_base
instead of_delegate
.This probably applies to the other
Delegating...
classes frompackage:collection
, but I haven't looked at them too carefully.