Skip to content

Selection Sort assignment solution #4

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

Closed

Conversation

aranasaurus
Copy link
Contributor

No description provided.

// You may declare array argument with var keyword so that it is copied.

for j in array.startIndex..<array.endIndex - 1 {
Copy link
Owner

Choose a reason for hiding this comment

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

Do we have any particular reason to use startIndex and endIndex here? for j in 0..<array.count - 1 would do the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I generally lean toward using start/endIndex for future-proofing, I guess. In this case we know it's an Array and therefore its index is Int, so it's unnecessary, but I've gotten into the habit of using the methods on the protocol (CollectionType) when I can.

Copy link
Owner

Choose a reason for hiding this comment

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

Yep makes sense 😄 Thanks for the PR!

@gmertk gmertk closed this Nov 27, 2015
diegopetrucci added a commit to diegopetrucci/SwiftAlgorithmsClassroom that referenced this pull request Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants