[swift-users] range(of:options:range:locale:) with partial ranges

Martin R martinr448 at gmail.com
Thu Sep 21 04:44:34 CDT 2017


The range(of:options:range:locale:) method of StringProtocol does not accept a partial range as search range. Example (Xcode 9, Swift 4):

    let str = "foo"
    let pos = str.startIndex
    let r = str.range(of: "f", range: pos...)
    // error: cannot convert value of type 'PartialRangeFrom<String.Index>'
    // to expected argument type 'Range<String.Index>?'

Is that because it is an NSString method imported to Swift? Would it make sense to file an enhancement request?

Regards, Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170921/56d1ac36/attachment.html>


More information about the swift-users mailing list