How to check if element exist in array with Swift

1 Answer

0 votes
var arr = ["swift", "c++", "php", "java"]
  
if arr.contains("swift") {
    print(true)
}

if !arr.contains("nodjs") {
    print(false)
}
   
   
   
   
/*
run:
 
true
false
  
*/

 



answered Sep 2, 2020 by avibootz
...