1 min readSep 13, 2017
I feel like this is more “swifty”
extension Optional where Wrapped == String {
var nonEmpty: String? {
switch self {
case .none: return nil
case .some(let string): return string.isEmpty ? nil : string
}
}
}