VYT
VYT

Reputation: 1071

Migration from swift2 to swift3 and changes for advanceBy for Range<String.Index>

There is a function

func find(... rangeString1: Range<String.Index>, ...) ...

and this function has in swift2

while i >= minimalIdentity{

var first = rangeString1.startIndex
var last = first.advancedBy(i, limit: rangeString1.endIndex)
...

Question is how should look the

var last  

in swift3

var first = rangeString1.lowerBound
var last = 

Upvotes: 0

Views: 480

Answers (2)

Tim Vermeulen
Tim Vermeulen

Reputation: 12562

Whatever string those indices belong to is responsible for this in Swift 3:

let first = rangeString1.lowerBound
let last = myString.index(first, offsetBy: i, limit: rangeString1.upperBound)

Upvotes: 1

Alexander
Alexander

Reputation: 63399

Just use endIndex:

var last = rangeString1.endIndex

Upvotes: 0

Related Questions