# \#set-collection

**URL:** https://forums.swift.org/tag/set-collection/827.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Passing a Collection to Set.contains(\_:) leads to confusing results](https://forums.swift.org/t/passing-a-collection-to-set-contains-leads-to-confusing-results/76393)

<div class="topic-metadata">

**Author:** [@marco.masser](https://forums.swift.org/u/marco.masser)\
**Replies:** 4\
**Last updated:** [June 17, 2025, 8:24pm UTC](https://forums.swift.org/t/passing-a-collection-to-set-contains-leads-to-confusing-results/76393 "2025-06-17T20:24:19Z")

</div>

There is a confusing behavior of Set.contains(\_:) when passing a collection that contains more than one element: let s: Set = \[1, 2, 3\] s.contains(\[1\]) // true s.contains(\[1\] as Set) // true s.contains(\[1, 2\]) // false …

---

## [Checking if two sets have elements in common](https://forums.swift.org/t/checking-if-two-sets-have-elements-in-common/64491)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 1\
**Last updated:** [April 19, 2023, 6:17pm UTC](https://forums.swift.org/t/checking-if-two-sets-have-elements-in-common/64491 "2023-04-19T18:17:30Z")

</div>

I had an instance when I was checking if two sets have elements in common: if !a.intersection(b).isEmpty { ... } when realised it would work quicker if I do it manually: extension Set { func containsMembers(from o…
