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

2.6.3 改进:闭包函数作为比较函数 #275

Closed
Shimingli opened this issue Aug 9, 2018 · 3 comments
Closed

2.6.3 改进:闭包函数作为比较函数 #275

Shimingli opened this issue Aug 9, 2018 · 3 comments

Comments

@Shimingli
Copy link

提示:哪一章节的问题,建议如何修改
import "sort"

func main() {
values := []int32{42, 9, 101, 95, 27, 25}

sort.Slice(values,  less func(i, j int) bool {
	return values[i] < values[j]
})

fmt.Println(values)

}

这个地方 less 这个关键字可以不要

@Shimingli
Copy link
Author

不对 应该是不能要,要了就报错了
image

@Shimingli
Copy link
Author

不过 大佬 辛苦了 学无止境

@chai2010
Copy link
Owner

chai2010 commented Aug 9, 2018

欢迎提交pr

chai2010 added a commit that referenced this issue Aug 27, 2018
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