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

类似的题目不一样的答案 #47

Open
epolar opened this issue Aug 18, 2021 · 1 comment
Open

类似的题目不一样的答案 #47

epolar opened this issue Aug 18, 2021 · 1 comment

Comments

@epolar
Copy link

epolar commented Aug 18, 2021

题目一
题目二
位于q007和q014的这两个题目问题是一样的,但是答案不一样,q007的答案更为准确,将题目二的代码改成这样就可以正确运行:

type Student struct {
	Age int
}
func main() {
	kv := map[string]*Student{"menglu": {Age: 21}}
	kv["menglu"].Age = 22
	s := []Student{{Age: 21}}
	s[0].Age = 22
	fmt.Println(kv, s)
}

我在stackoverflow上找到了和q007类似的解答:https://stackoverflow.com/a/32751792/4737579

@godaner
Copy link

godaner commented Sep 17, 2021

这个说法貌似更能接受 @epolar

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