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

【第 58 天】下面哪一行代码会 panic,请说明原因?(切片) #83

Open
Seekload opened this issue Oct 30, 2019 · 1 comment

Comments

@Seekload
Copy link
Owner

package main

func main() {
	x := make([]int, 2, 10)
	_ = x[6:10]
	_ = x[6:]
	_ = x[2:]
}
@tony2051
Copy link

tony2051 commented Nov 5, 2019

_ = x[6:] 会出错误,因为省略了第二个参数,第二个参数默认为 len(x) = 2,所以这一行代码就就是
_ = x[6:2]

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