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

sort: use By as a type name in struct definition #6708

Closed
donovanhide opened this issue Nov 2, 2013 · 3 comments
Closed

sort: use By as a type name in struct definition #6708

donovanhide opened this issue Nov 2, 2013 · 3 comments

Comments

@donovanhide
Copy link
Contributor

@donovanhide donovanhide commented Nov 2, 2013

In the planet sorter example, on line 38, the By type is defined but not used:

http://tip.golang.org/src/pkg/sort/example_keys_test.go#L38

Replace:

by      func(p1, p2 *Planet) bool // Closure used in the Less method.

with:

by     By // Closure used in the Less method.
@robpike
Copy link
Contributor

@robpike robpike commented Nov 3, 2013

Comment 1:

It's used several times in the example function. It could be used in the struct
definition as well, but does it help much to do so?
@donovanhide
Copy link
Contributor Author

@donovanhide donovanhide commented Nov 3, 2013

Comment 2:

Apart from less keystrokes, I agree, there is no very compelling reason to do so :-)
It was pleasant to see an example of function literals and type conversions in this bit
of code; it is a slightly under documented aspect of Go, apart from:
http://golang.org/doc/codewalk/functions/
Maybe a blog post on the subject would be good?
@robpike
Copy link
Contributor

@robpike robpike commented Nov 4, 2013

Comment 3:

Status changed to WontFix.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.