Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
to your account
Inspired by https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160718/024896.html.
Currently, the empty string has unique prefix/suffix behavior compared to other strings:
let E = ""
let a = "a" // any non-empty string
let b = "b" // any non-empty string
a == a // true
a.hasPrefix(a) // true
a.hasSuffix(a) // true
(a+b).hasSuffix(b) // true
(b+a).hasPrefix(b) // true
E == E // true
E.hasPrefix(E) // false
E.hasSuffix(E) // false
(a+E).hasSuffix(E) // false
(E+a).hasPrefix(E) // false
This is consistent with NSString and Foundation but conflicts with other languages and with concatenation - for all non-empty strings a and b, (a+b) has a prefix of a and a suffix of b.
The text was updated successfully, but these errors were encountered:
Comment by Alexander Lash (JIRA)
Resolved in #3651
Sorry, something went wrong.
No branches or pull requests