# isContained(in array:) extension of Equatable

**URL:** <https://forums.swift.org/t/iscontained-in-array-extension-of-equatable/20223>\
**Category:** Pitches\
**Created:** [February 6, 2019, 8:35pm UTC](https://forums.swift.org/t/iscontained-in-array-extension-of-equatable/20223 "2019-02-06T20:35:45Z")\
**Posts on this page:** 1\
**Showing post:** 28

<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:** [February 7, 2019, 8:19pm UTC](https://forums.swift.org/t/iscontained-in-array-extension-of-equatable/20223/28 "2019-02-07T20:19:02Z")

</div>

Ooh, a fellow Ukelele-ist!

On my custom layout it’s ⌥⇧L to enter Logic mode, then P to type ∈ (not sure why I put it there exactly. Probably so it’s next to ⋃ (U), ⋂ (I), and ∅ (O). E was already taken by ∃.)

• • •

I think the larger issue in this thread has to do with inversion of method calls during a functional-style chain. Until we have a good story there, I don’t think it’s worth special-casing this sort of thing.

For those who want it, the generic implementation of the OP’s request is trivially composable from existing features:

```swift
extension Equatable {
  func isIn<S: Sequence>(_ s: S) -> Bool where S.Element == Self {
    return s.contains(self)
  }
}

```

And the variadic version too:

```swift
extension Equatable {
  func isOneOf(_ s: Self...) -> Bool {
    return s.contains(self)
  }
}

```

---

_[View the full topic](https://forums.swift.org/t/iscontained-in-array-extension-of-equatable/20223)._
