Answers for "containing element in dictionary swift"

1

swift dictionary contains key

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

// OR
extension Dictionary {
  func contains(key: Key) -> Bool {
    self[key] != nil
  }
}
Posted by: Guest on June-07-2021

Code answers related to "containing element in dictionary swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language