Skip to content
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

Possible clarification needed for Uniq function? #87

Closed
cmaster11 opened this issue Jun 18, 2020 · 1 comment
Closed

Possible clarification needed for Uniq function? #87

cmaster11 opened this issue Jun 18, 2020 · 1 comment

Comments

@cmaster11
Copy link

cmaster11 commented Jun 18, 2020

Hi! I was browsing through the code, and for the Uniq function I noticed this line:

value.Index(j).Set(val)

Now, the code value.Index(j).Set(val) is actively editing the input argument. Could you help me understand why this line exists/does what it does? I'm failing to grasp the logic behind it 😅

Edit: A coffee helped. I understand the algorithm itself, it edits the input argument and a copy is therefore not needed, using j as a secondary index. Though, there is no mention in the comment/function doc (unless I missed it somewhere), that it actually alters the original array! Maybe this issue is more related to this, I was not understanding why the input argument was being altered.

Thanks a lot,
Alberto

@cmaster11 cmaster11 changed the title Possible clarification needed? Possible clarification needed for Uniq function? Jun 18, 2020
@thoas
Copy link
Owner

thoas commented Jun 23, 2020

hi @cmaster11

I think it's a mistake it should not edit the input argument and instead returns a copy of it.

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

No branches or pull requests

2 participants