[swift-evolution] Change Request: Make myString.hasPrefix("") and myString.hasSuffix("") return true
Ted F.A. van Gaalen
tedvgiosdev at gmail.com
Tue Jul 19 07:44:15 CDT 2016
“true” ? am I going nuts ? :o)
var str = "Hello, playground"
print( str.hasPrefix("”)) // case 1 : false
print( str.hasSuffix("”)) // case 2 : false
print("" == “a” ) // case 3 : false
Currently, all cases above evaluate to “false”
i think that is correct, because:
How can an empty string be a prefix or suffix value?
as there is no empty string present in a non-empty string.
Note that if case 1 and case 2 would evaluate to “true”,
it would conflict with case 3.
Can’t imagine that case 3 should in future also result in “true”
Also I hope that changes to String functionality
for Swift 4 are not backward breaking changes
even the more for string handling, because Strings
are heavily used in most apps.
I am firmly convinced that all future releases of Swift
should compile Swift 3 and higher source files without
any changes 100 % flawlessly! This prevents early diminishing
of Swift’s popularity, especially with those building large
codebases using Swift.
I’ve started a thread about this a week ago,
however no one found this important enough to
share their opinions with me yet, or were too busy with
other subjects to do so.
Increasingly I have dreams, me
programming complete apps in Smalltalk
and then automagically generate
an macOS, tvOS or iOS runtime app of it.
(I have also dreams of this world becoming
a nice and peaceful placebut that is
beyond the context of this forum)
> on Mon Jul 18 2016, Kevin Nattinger <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> I agree, true is definitely the expected behavior. In particular, it
>> seems absurd to me that `a.hasPrefix(b)` and `a.hasSuffix(b)` could be
>> false when `a == b` is true.
> I expect to be reworking Strings for Swift 4, and this is one of the
> many things we plan to address.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution