Answers for "swift contains array"

0

check if all array elements match closure swift

let names = ["Sofia", "Camilla", "Martina", "Mateo", "Nicolás"]
let allHaveAtLeastFive = names.allSatisfy({ $0.count >= 5 })
// allHaveAtLeastFive == true
Posted by: Guest on May-26-2020
0

check if array contains value swift

//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
Posted by: Guest on August-12-2021

Code answers related to "swift contains array"

Code answers related to "Swift"

Browse Popular Code Answers by Language