Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 4.2 compiler error in String+CreditCardRow #12

Open
mrhaxic opened this issue Sep 9, 2018 · 2 comments
Open

Swift 4.2 compiler error in String+CreditCardRow #12

mrhaxic opened this issue Sep 9, 2018 · 2 comments

Comments

@mrhaxic
Copy link

mrhaxic commented Sep 9, 2018

To avoid the compiler error of subscript Range we have to use the following

        let start = index(startIndex, offsetBy: r.lowerBound)
        let end = index(start, offsetBy: r.upperBound - r.lowerBound)
        let range: Range<Index> = start..<end
        return String(self[range])
    }

Thanks.

@elgartoinf
Copy link
Contributor

Regards!
change the code for this and the problem is solved

subscript (r: Range<Int>) -> String {
        let start = self.index(startIndex, offsetBy: r.lowerBound)
        let end = self.index(start, offsetBy: r.upperBound - r.lowerBound)
        return String(self[start..<end])
 }

@palaryan
Copy link

palaryan commented Jan 5, 2019

Thank you! This was exactly the issue I was having.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants