Skip to content

Instantly share code, notes, and snippets.

@Anatoli-Petrosyants
Created March 6, 2018 12:56
Show Gist options
  • Select an option

  • Save Anatoli-Petrosyants/ebda6ddef5cf380c31535ad68b027e50 to your computer and use it in GitHub Desktop.

Select an option

Save Anatoli-Petrosyants/ebda6ddef5cf380c31535ad68b027e50 to your computer and use it in GitHub Desktop.
protocol StringType {
var isEmpty: Bool { get }
}
extension String : StringType { }
extension Optional where Wrapped: StringType {
var isNullOrEmpty: Bool {
return self?.isEmpty ?? true
}
}
extension Optional where Wrapped: CollectionType {
var isNullOrEmpty: Bool {
return self?.isEmpty ?? true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment