Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

modular no-temp swap #2

Closed
wants to merge 1 commit into from
Closed

modular no-temp swap #2

wants to merge 1 commit into from

Conversation

Rudxain
Copy link

@Rudxain Rudxain commented Sep 10, 2023

This uses destructuring syntax, to avoid the potential confusion of temporary vars. It also defines a swap fn that mutates whatever array is passed as input, without returning it.

A more functional approach would be to shallow-copy the array, mutate the copy, then return it. Should we do that instead?

BTW, let temp can be replaced by const temp (#3 closes it)

@Rudxain
Copy link
Author

Rudxain commented Sep 10, 2023

Nvm, I think it's better to keep the code as-is, for better variety. I've seen other files already using destructuring syntax, and other files using the modular-temp approach

@Rudxain Rudxain closed this Sep 10, 2023
@Rudxain Rudxain deleted the patch-1 branch September 10, 2023 06:31
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant