Skip to content

Comments

Fix coordinate(distance:.. crash#271

Merged
bsudekum merged 2 commits intomasterfrom
crash-fix
Jun 13, 2017
Merged

Fix coordinate(distance:.. crash#271
bsudekum merged 2 commits intomasterfrom
crash-fix

Conversation

@bsudekum
Copy link
Contributor

@bsudekum bsudekum commented Jun 9, 2017

Shouldn't always assume that those coordinates are always there.

/cc @frederoni @ericrwolfe

@bsudekum bsudekum requested review from ericrwolfe and frederoni June 9, 2017 18:51
if timeToTravel > 1 {
let newCoordinate = coordinate(at: speed, fromStartOf: [location.coordinate, nextLocation.coordinate])
let newLocation = SimulatedLocation(coordinate: newCoordinate!,
guard let newCoordinate = coordinate(at: speed, fromStartOf: [location.coordinate, nextLocation.coordinate]) else { return processedLocations }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure if this is the right thing to return early here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling return in the guard statement here will break out of the for loop prematurely. Seems like it might be better to continue instead of returning early.

if timeToTravel > 1 {
let newCoordinate = coordinate(at: speed, fromStartOf: [location.coordinate, nextLocation.coordinate])
let newLocation = SimulatedLocation(coordinate: newCoordinate!,
guard let newCoordinate = coordinate(at: speed, fromStartOf: [location.coordinate, nextLocation.coordinate]) else { return processedLocations }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling return in the guard statement here will break out of the for loop prematurely. Seems like it might be better to continue instead of returning early.

@bsudekum
Copy link
Contributor Author

bsudekum commented Jun 9, 2017

@ericrwolfe fixed

@bsudekum bsudekum merged commit 3b9cd49 into master Jun 13, 2017
@bsudekum bsudekum deleted the crash-fix branch June 13, 2017 15:36
@1ec5 1ec5 added this to the v0.5.0 milestone Jul 9, 2017
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

Successfully merging this pull request may close these issues.

3 participants