I'd like to create an extension off all types that have the .contains
API.
For example, I did this for strings, but would like to expand it for all types:
func within(values: [String]) -> Bool {
return values.contains(self)
}
With this, instead of this:
["abc", "def", "ghi"].contains("def")
I can do this for convenience:
"def".within(["abc", "def", "ghi"])
But I'd like to work with anything like this for example:
[.North, .South].contains(.West)
So I can do this with enums:
let value = .West
value.within([.North, .South])
Is creating a broad extension possible for this scenario?