[swift-evolution] Change Request: Make myString.hasPrefix("") and myString.hasSuffix("") return true

Xiaodi Wu xiaodi.wu at gmail.com
Wed Jul 20 17:58:01 CDT 2016


I'd run this by someone who actually knows math, but afaik there are
finitely many empty strings in any given string.

How many e's are in any given string? (Ignoring Unicode issues for now,)
for each index in the string's indices, form a substring one character in
length starting at that index and compare the value of that substring to e.

How many empty strings are in any given string? For each index in the
string's indices, form a substring zero characters in length starting at
that index and compare the value of that substring to an empty string.


On Wed, Jul 20, 2016 at 17:35 Guillaume Lessard <glessard at tffenterprises.com>
wrote:

>
> > On 20 juil. 2016, at 14:21, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> >
> > Doesn't your second argument undermine your first? If it's a trivial
> solution and one rarely ever considers empty strings when invoking
> `hasPrefix`, then returning the technically correct result must be a
> trivial departure in behavior.
>
> I specifically used an example where the trivial solution (y=0 instead of
> y=exp(x)) is a pitfall.
>
> How many empty strings are contained in any given string?
> If the answer is infinitely many, it sounds like a pitfall to me.
>
> Cheers,
> Guillaume Lessard
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160720/51f0f51c/attachment.html>


More information about the swift-evolution mailing list