Skip to content

Instantly share code, notes, and snippets.

@fictorial
Created September 8, 2017 14:40
Show Gist options
  • Save fictorial/6bbf9bcc8e34dfb409663458d6bdc655 to your computer and use it in GitHub Desktop.
Save fictorial/6bbf9bcc8e34dfb409663458d6bdc655 to your computer and use it in GitHub Desktop.
empty if nil
extension Optional where Wrapped == String {
var nilIfEmpty: String? {
guard let strongSelf = self else {
return nil
}
return strongSelf.isEmpty ? nil : strongSelf
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment