Skip to content
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

Iterable<T>.containsAny(Iterable<T>) #41

Merged
merged 1 commit into from Jan 22, 2020

Conversation

ThinkDigitalSoftware
Copy link
Contributor

@ThinkDigitalSoftware ThinkDigitalSoftware commented Jan 21, 2020

Add Iterable.containsAny(listB).
This will search through a list and returns true if any elements in listB are present in this

@simc
Copy link
Owner

simc commented Jan 21, 2020

Please add a description to your next PR.

I think the name of the method is not very expressive. Also, you can achieve the same using someList.intersect(otherList).isNotEmpty which in my opinion is easier to read...

@ThinkDigitalSoftware
Copy link
Contributor Author

Sorry, description added. As far as the name, it's consistent with other list methods like add and addAll, therefore, contains and containsAll. As for ease of reading, someList.intersect(otherList).isNotEmpty requires more knowledge of what intersect does and why .isNotEmpty means that the list contains all of the other elements, rather than my implementation. I'd argue that it's simply more concise.

@simc
Copy link
Owner

simc commented Jan 21, 2020

@passsy what do you think?

test/iterable_test.dart Outdated Show resolved Hide resolved
@passsy passsy changed the title master Iterable<T>.containsAny(Iterable<T>) Jan 22, 2020
@passsy
Copy link
Collaborator

passsy commented Jan 22, 2020

I think the method makes sense and is consistent with the rest of the API. I see it using myself. intersect works but I have to lookup the Venn Diagrams every time I use one of intersect or union.

Copy link
Contributor Author

@ThinkDigitalSoftware ThinkDigitalSoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed Iterable.containsAny test

@simc
Copy link
Owner

simc commented Jan 22, 2020

Thank you!

@simc simc merged commit da180dd into simc:master Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants