如何检测一个字符串是否包含一个字符串数组(单词)中的任何成员?
这是字符串数组:
let str:String = "house near the beach"
let wordGroups:[String] = ["beach","waterfront","with a water view","near ocean","close to water"]
以下代码无法编译。let match:Bool = wordGroups.contains(where: str.contains)
true
)。您遇到了什么错误? - John Montgomerystr
永远不会为空,否则请小心。 - John Montgomery