Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift array contains

let elements = [1, 2, 3, 4, 5]
if elements.contains(5) {
    print("yes")
}
Comment

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
Comment

PREVIOUS NEXT
Code Example
Swift :: get height of navigation bar swift 
Swift :: add to beginning of array swift 
Swift :: swiftui create search bar 
Swift :: swiftui actionsheet 
Swift :: swift edit constraint programmatically 
Swift :: wkwebview load delegate in swift 
Swift :: load image from url in Image swiftui (iOS 15) 
Swift :: remove all add TapGestureRecognizer swift 
Swift :: swift file size from url 
Swift :: swift iterate through string 
Swift :: how to bold 1 word swift 
Swift :: guard let swift 
Swift :: how to recieve hex value from NSData swift 
Swift :: swift extension Array where element 
Swift :: swift how to set warning message 
Swift :: swift enum xib 
Swift :: swift extension 
Swift :: check if UIView is UIButton or UILabel not 
Swift :: bold world in text swift 
Swift :: swiftui divider remove padding 
Swift :: Swift Assigning and accessing a value from an optional 
Swift :: Changing default url to static-media in Flask 
Swift :: Swift Print Variables and Strings together 
Swift :: Generic Function Swift 
Swift :: Trailing Closure Swift 
Swift :: swift isMemberOf 
Swift :: Swift Assign Values to Variables 
Swift :: how to do corner radius from button image in swift 
Ruby :: ruby delete file 
Ruby :: rails generate model 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =