[swift-dev] Implementing hasPrefix and hasSuffix

Alex Blewitt alex.blewitt at gmail.com
Tue Dec 22 15:28:38 CST 2015

I raised https://bugs.swift.org/browse/SR-337 <https://bugs.swift.org/browse/SR-337> to implement hasPrefix and hasSuffix in Swift (instead of depending on the Objective-C implementation and only being available for OSX at present.

I have an implementation which I’d like to create a pull request for but don’t know where it should go. The current implementation is at

https://github.com/apple/swift/blob/master/stdlib/public/core/StringLegacy.swift#L98 <https://github.com/apple/swift/blob/master/stdlib/public/core/StringLegacy.swift#L98>

inside ‘StringLegacy.swift’ but I’d presume it’s better to live elsewhere.

In addition this uses the character view which I’m not sure follows the normalisation required for comparisons; or if there is some different normalisation routines that need to be written either.

Finally it’s not clear if this the right way to solve the problem, or if the implementation should be in the open-source version of the Foundation NSString implementation.

Happy to take comments by mail or on the bug.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151222/9d2a8958/attachment.html>

More information about the swift-dev mailing list