Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

swift 5 check if dictionary contains key

if let key = self.dictionary["key"] {
	print(key) // returns value
}

// OR
extension Dictionary {
  func contains(key: Key) -> Bool {
    self.index(forKey: key) != nil
  }
}
 
PREVIOUS NEXT
Tagged: #swift #check #dictionary #key
ADD COMMENT
Topic
Name
2+5 =