Skip to content

Move redundant assertion out of loop#12

Merged
afd merged 1 commit into
afd:masterfrom
kashparty:patch-1
Jan 16, 2022
Merged

Move redundant assertion out of loop#12
afd merged 1 commit into
afd:masterfrom
kashparty:patch-1

Conversation

@kashparty

Copy link
Copy Markdown
Contributor

Just something small I found: as far as I can tell, it's redundant to assert that numChosenSoFar < numbers.length more than once, since neither value is changed within the loop. I think it's better to move the check outside the loop so that it's only executed once.

Small change: the code in the for loop does not affect the assertion, so it does not need to be checked more than once.

@afd afd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Good spot, thanks!

@afd afd merged commit 12606ed into afd:master Jan 16, 2022
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.

2 participants