# Array.removeAll(where:) duplication

**URL:** <https://forums.swift.org/t/array-removeall-where-duplication/70597>\
**Category:** Using Swift\
**Tags:** array\
**Created:** [March 12, 2024, 8:48am UTC](https://forums.swift.org/t/array-removeall-where-duplication/70597 "2024-03-12T08:48:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [March 12, 2024, 8:48am UTC](https://forums.swift.org/t/array-removeall-where-duplication/70597/1 "2024-03-12T08:48:06Z")

</div>

Why is this method duplicated?

 ![Screenshot](https://global.discourse-cdn.com/swift/original/3X/a/0/a064695647ec7f9a447e1646d3b98c2c28600186.jpeg)

---

<div class="post-metadata">

**Author:** ![Nevin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nevin/32/617_2.png) [@Nevin](https://forums.swift.org/u/Nevin)\
**Post date:** [March 12, 2024, 2:02pm UTC](https://forums.swift.org/t/array-removeall-where-duplication/70597/2 "2024-03-12T14:02:27Z")

</div>

Where exactly are you seeing this?

That method is declared on `RangeReplaceableCollection`, and the standard library has two default implementations for it, one with and one without the additional constraint `Self: MutableCollection`.

However only the former should be picked up by `Array`.

---

<div class="post-metadata">

**Author:** ![itaiferber](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/itaiferber/32/33840_2.png) [@itaiferber](https://forums.swift.org/u/itaiferber)\
**Post date:** [March 12, 2024, 2:03pm UTC](https://forums.swift.org/t/array-removeall-where-duplication/70597/3 "2024-03-12T14:03:07Z")

</div>

`RangeReplaceableCollection` offers two default implementations of `removeAll(where:)`:

1. A generic implementation requiring only `RangeReplaceableConformance` [swift/stdlib/public/core/RangeReplaceableCollection.swift at 27702fa1155b9e23fde7234492e72305c4e3a34a · apple/swift · GitHub](https://github.com/apple/swift/blob/27702fa1155b9e23fde7234492e72305c4e3a34a/stdlib/public/core/RangeReplaceableCollection.swift#L1172)
2. A more efficient implementation when the type conforms to `MutableCollection`: [swift/stdlib/public/core/RangeReplaceableCollection.swift at 27702fa1155b9e23fde7234492e72305c4e3a34a · apple/swift · GitHub](https://github.com/apple/swift/blob/27702fa1155b9e23fde7234492e72305c4e3a34a/stdlib/public/core/RangeReplaceableCollection.swift#L1145)

`Array` conforms to `MutableCollection`, so it gets the latter, but the generated interface still ends up showing both.

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [March 12, 2024, 2:50pm UTC](https://forums.swift.org/t/array-removeall-where-duplication/70597/4 "2024-03-12T14:50:23Z")

</div>

> [@itaiferber](#):
>
> `Array` conforms to `MutableCollection`, so it gets the latter, but the generated interface still ends up showing both.

the [generated documentation](https://swiftinit.org/docs/swift/swift/array#s:SmsE9removeAll5whereySb7ElementQzKXE_tKF) for `Array` also contains the duplicated method, which is a strong indication that this bug also exists in lib/SymbolGraphGen.

---

<div class="post-metadata">

**Author:** ![Kyle-Ye](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kyle-ye/32/19686_2.png) [@Kyle-Ye](https://forums.swift.org/u/Kyle-Ye)\
**Post date:** [March 12, 2024, 4:29pm UTC](https://forums.swift.org/t/array-removeall-where-duplication/70597/5 "2024-03-12T16:29:13Z")

</div>

> [@tera](#):
>
> Why is this method duplicated?

I'm also seeing this recently. Thanks for opening the topic here and looks we already have an answer for it.

> [@taylorswift](#):
>
> the [generated documentation](https://swiftinit.org/docs/swift/swift/array#s:SmsE9removeAll5whereySb7ElementQzKXE_tKF) for `Array` also contains the duplicated method, which is a strong indication that this bug also exists in lib/SymbolGraphGen.

Besides fix it in the compiler side, I was wondering whether swift-docc will be effected by the bug?

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [March 12, 2024, 4:38pm UTC](https://forums.swift.org/t/array-removeall-where-duplication/70597/6 "2024-03-12T16:38:43Z")

</div>

i think it does, but they don’t appear adjacent to one another in generated DocC docs because DocC splits off protocol extension members into a [separate section](https://developer.apple.com/documentation/swift/array/rangereplaceablecollection-implementations).
