-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
slices: Equal should call out handling of nil #68472
Comments
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
The doc does explain how nil slices are handled, because it says exactly what the function does. But we can add another sentence if you like. |
I agree the current wording is correct, but my point is that a little more information (even if strictly redundant) is helpful. After all, we called out the behavior of NaNs, which is technically covered by "all elements equal". |
FWIW, when I read the current text my immediate thought was: that sure sounds like it's implying that empty and I think mentioning it explicitly (rather than just implying it) would be worthwhile given that other parts of the language, and also various third-party libraries, are not consistent in how they handle this difference. |
Change https://go.dev/cl/599816 mentions this issue: |
Go version
go1.22.0
What did you do?
Read the docs for
slices.Equal
What did you see happen?
Saw:
What did you expect to see?
Something like:
Nilness of slices is a more common occurance than NaNs, yet NaNs get called out, but nilness does not. In both cases, the current behavior is implicit with the previous prose, but it's helpful to call out edge cases.
The text was updated successfully, but these errors were encountered: