📌  相关文章
📜  检查数组是否包含值 swift 代码示例

📅  最后修改于: 2022-03-11 15:01:00.644000             🧑  作者: Mango

代码示例1
//we can use the .contains element
//Declaration:

func contains(_ element: Element) -> Bool

//Thus, it accepts an array and a value, and checks if the value if present in the array
//Example:

sampleArray = ["Apple", "Berry", "Banana"]
print(sampleArray.contains("Apple"))
//The contains function checks in the sampleArray if an element called Apple exists. If it exists, it prints true.
//Therefore prints true