<div dir="ltr"><div class="gmail_default">This almost seems more like a bug than a change request. Definitely agree.</div><div class="gmail_default"><br></div><div class="gmail_default">> +1 - this shouldn't be hard to fix either - in StringLegacy.swift, add a check for prefix.isEmpty and return true...<br>> <br>> > On Jul 18, 2016, at 7:36 PM, Chris Denter via swift-evolution<<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>(mailto:<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>)>wrote:<br>> > Hello –<br>> > <br>> > Currently, the standard library String functions .hasPrefix() and .hasSuffix() will return false when given the empty string as input:<br>> > <br>> > $ swift<br>> > 1>"".hasPrefix("")<br>> > $R0: Bool = false<br>> > 2>"foo".hasPrefix("")<br>> > $R1: Bool = false<br>> > 3>"foo".hasSuffix("")<br>> > $R2: Bool = false<br>> > <br>> > <br>> > <br>> > This feels unexpected. The reason the methods behave this way seems to bea leaked implementation detail(<a href="https://twitter.com/cdntr/status/755059959713427456">https://twitter.com/cdntr/status/755059959713427456</a>).<br>> > Some languages, such as Python, return True in these cases -- perhaps motivated by the `someSet.contains(emptySet) == true` analogy.<br>> > <br>> > The ship has sailed for NSString and Foundation, but we might want to bite the bullet and fix this for Swift before 3.0 makes that much harder.<br>> > <br>> > Thank you so much for your time,<br>> > <br>> > Chris_______________________________________________<br>> > swift-evolution mailing list<br>> > <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>(mailto:<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>)<br>> > <a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>> <br>> <br>> <br></div><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">-Tal</div></div>
</div>