-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zip can only zip iterables of the same type #91
Comments
Rough new implementation that works for me: extension IterableZip<E> on Iterable<E> {
Iterable<V> zipWith<R, V>(Iterable<R> other, V Function(E a, R b) transform) sync* {
final it1 = iterator;
final it2 = other.iterator;
while (it1.moveNext() && it2.moveNext()) {
yield transform(it1.current, it2.current);
}
}
} |
Yep - this works, but unfortunately it also breaks consumer code: The second parameter will now become @leisim @passsy it would be great if you can add some guidance on how you would like this to be handled. I basically see two options:
|
@mreichelt Thanks for the detailed proposal. Is it only me or is this a bug in Dart? In my opinion Dart should be able to infer the types correctly without manual annotations. I don't think we should add a |
Ok, thanks! Then, at least I'll add some docs to the |
That's a problem I've also ran into when building Definitely a dart issueI think right now would be a good time to open a dart-lang/sdk issue about this. I searched for quite a while but haven't found anything related. detailsFirst guesses: TODO: come up with an easier example than Split zip in two methodsSince we're doing a breaking API change, I was thinking about aligning the In kt_dart I've split zip into two methods
I decided against it because Dart doesn't offer tuples in the Dart SDK. Therefore we are left with a single zip method and don't have to think about the naming conflict. Going forward
|
The zip method is especially useful when we can zip items of different types - but
zip
in dartx is implemented to only accept a right-hand iterable of the same type. So things like this work:But this doesn't:
We can try to change the implementation of the original
zip
, but then we must make sure we don't break any calling code. So let's test this thoroughly. 🤓The text was updated successfully, but these errors were encountered: