You can use the is keyword to distinguish between types, and then use the code snippet using the Airspeed Velocity speed above to search ... Here is an example that you can modify and add additional types if necessary:
if resultArray[0] is String { found = contains(resultArray) { ($0 as? String) == "hello" } } else if resultArray[0] is Int { found = contains(resultArray) { ($0 as? Int) == 50 } }
NOTE. You said that your array will only contain 1 type at a time - this is important.
source share