Pass by value in for loop, not by reference. #953
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When getting
--json
output of a list of organization members, the entire list of members were duplicates of the last member found. The issue is this list where all entries were the duplicated member, rather than a list where all entries were unique members.The problem was that there was a for loop that was passing a pointer to a loop variable, to a function, where it was being used later; passing by reference. This meant that the only value used was the last value in the loop, as the value of the pointer changed with each iteration.
🔧 Changes
This PR passes the value of the member to the function, forcing a copy of the current iteration value, and preserving it from changes by the next iteration: pass by value.
📚 References
🔬 Testing
📝 Checklist