Skip to content

Instantly share code, notes, and snippets.

@eonist
Last active July 7, 2020 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eonist/dfa1412dc70eb93b2c516b35dd0daa1c to your computer and use it in GitHub Desktop.
Save eonist/dfa1412dc70eb93b2c516b35dd0daa1c to your computer and use it in GitHub Desktop.
/**
* Asserter
*/
extension Array {
/**
* Asserts if array has nil values
* ## Examples:
* let someArr: [Int?] = [1,2,nil]
* someArr.hasNil() // true
* [1,2,2].hasNil() // false
*/
public func hasNil<T>() -> Bool where Element == T? {
self.contains { $0 == nil }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment