filterNotNullTo<C extends KtMutableCollection> method
C
filterNotNullTo<C extends KtMutableCollection>(
- C destination
Appends all elements that are not null
to the given destination
.
destination
is not type checked by the compiler due to https://github.com/dart-lang/sdk/issues/35518,
but will be checked at runtime.
C
actually is expected to be C extends KtMutableCollection<T>
Implementation
// TODO Change to `C extends KtMutableCollection<T>` once https://github.com/dart-lang/sdk/issues/35518 has been fixed
C filterNotNullTo<C extends KtMutableCollection<dynamic>>(C destination) {
assert(() {
if (destination is! KtMutableCollection<T> && mutableListOf<T>() is! C) {
throw ArgumentError(
"filterNotNullTo destination has wrong type parameters."
"\nExpected: KtMutableCollection<$T>, Actual: ${destination.runtimeType}"
"\ndestination (${destination.runtimeType}) entries aren't subtype of "
"map ($runtimeType) entries. Entries can't be copied to destination."
"\n\n$kBug35518GenericTypeError");
}
return true;
}());
for (final element in iter) {
if (element != null) {
destination.add(element);
}
}
return destination;
}