Check whether a string is empty:
if str.isEmpty {
// do something if the string is empty
}
// If the string is empty, replace it with a fallback:
let result = str.isEmpty ? "fallback string" : str
Check whether two strings are equal (in the sense of Unicode canonical equivalence):
"abc" == "def" // false
"abc" == "ABC" // false
"abc" == "abc" // true
// "LATIN SMALL LETTER A WITH ACUTE" == "LATIN SMALL LETTER A" + "COMBINING ACUTE ACCENT"
"\u{e1}" == "a\u{301}" // true
Check whether a string starts/ends with another string:
"fortitude".hasPrefix("fort") // true
"Swift Language".hasSuffix("age") // true