Skip to content

feat: Add zipWithNext

Luan Nico requested to merge luannico/dartlin:luan.zip-with-next into master

Description

Adds a zipWithNext function, similar to kotlin's.

I cannot add the transform parameter because dart doesn't support overloading, but it can be easily replaced by chaining this with map.

I added a new optional parameter to close the loop that I found useful. That is not kotlin standard though, and I can remove.

Example usage: convert list of vertices to list of edges of a polygon.


In order to facilitate testing, I added equals & hashcode impl to the Pair class. I think that is overall useful as I expect Pair to be a "data class" and delegate equals to the types of first/second.

However that is not mandatory for this change, if you don't like it I can revert it and add extra code on the tests to properly compare two Pairs.

Checklist

Before you create this MR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting MRs.
  • My MR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The flutter analyzer (flutter analyze) does not report any problems on my MR.
  • I read and followed the Flutter Style Guide.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I am willing to follow-up on review comments in a timely manner.
  • I am done with this MR and removed the Draft status, by clicking on the Mark as ready button in this MR

Breaking Change

Does your MR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.
Edited by Luan Nico

Merge request reports