How to check if string exists in array in Swift

1 Answer

0 votes
var arr = ["swift", "c++", "php", "java", "python"]

if arr.contains("swift") {
    print(true)
}

if !arr.contains("c#") {
    print(true)
}



/*
run:

true
true

*/

 



answered Nov 8, 2020 by avibootz
...