Answers for "swift dictionary contains"

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 "Swift"

Browse Popular Code Answers by Language