Friday, November 4, 2016

Check optional + empty string together

Apart from checking nil from an optional string, it's pretty common for us to check whether or not that optional as an empty string. e.g: ""

I found this wonderful solution, credits to StackOverflow once more.

(string ?? "").isEmpty

Source: http://stackoverflow.com/questions/29381994/swift-check-string-for-nil-empty

No comments:

Post a Comment