Swift检查集合是否包含值
示例
var favoriteColors: Set = ["Red", "Blue", "Green"]//favoriteColors = {"Blue", "Green", "Red"}
您可以使用该contains(_:)方法检查集合是否包含值。如果集合包含该值,它将返回true。
if favoriteColors.contains("Blue") {print("Who doesn't like blue!")
}
// Prints "Who doesn't like blue!"
以上是 Swift检查集合是否包含值 的全部内容, 来源链接: utcz.com/z/334545.html