-
Notifications
You must be signed in to change notification settings - Fork 179
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
Fixed deprecation warnings and index increment #21
Conversation
Hey @vfn thank you for the PR |
@andreacremaschi I forgot to update the travis file to use It looks like a xctool issue facebookarchive/xctool#666 |
@@ -184,9 +184,10 @@ public struct CoordinatesCollection: SequenceType { | |||
|
|||
public func generate() -> AnyGenerator<Coordinate> { | |||
var index: UInt32 = 0 | |||
return anyGenerator { | |||
return AnyGenerator { | |||
index += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a second check, this is wrong: index
should be incremented AFTER accessing the element, not BEFORE, something like this:
public func generate() -> AnyGenerator<T> {
var index: Int32 = 0
return AnyGenerator {
if index < self.count {
let item = self[index]
index = index + 1
return item
}
return nil
}
}
thanks! 🍻 |
👍 |
The if inside the generate methods would test index and then increment it, allowing it to go out of bounds.