I'm trying to evaluate if an entered string partially matches any item in an array. When I use the following method in playgrounds it seems to work properly. However, when I use the exact same method in Xcode 9.0 beta 6 (9M214v) it doesn't return the correct answer.
func isValid(_ item: String) -> Bool {
let whitelist = ["https://apple.com","https://facebook.com","https://stackoverflow.com"]
return whitelist.contains(where: {$0 <= item ? true : false })
}
There's also anomalies like when I passed in "https://twitter.com" it'll return true. Am I nuts? And while I'm here, anyone have a different approach to solve this problem?
$0 <= itemwhat does that mean ?$0 <= item?