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

[勘误]反馈一个第M章第N节的错别字 #107

Open
junjiezou1 opened this issue Dec 20, 2023 · 2 comments
Open

[勘误]反馈一个第M章第N节的错别字 #107

junjiezou1 opened this issue Dec 20, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@junjiezou1
Copy link

问题描述
第一章,slice篇的问题三,下面是原文。

程序解释:该段程序源自select的实现代码,程序中定义一个长度为10的切片order,pollorder和lockorder分别是对order切片做了order[low:high:max]操作生成的切片,最后程序分别打印pollorder和lockorder的容量和长度。

参考答案:order[low:high:max]操作意思是对order进行切片,新切片范围是[low, high),新切片容量是max。order长度为2倍的orderLen,pollorder切片指的是order的前半部分切片,lockorder指的是order的后半部分切片,即原order分成了两段。所以,pollorder和lockerorder的长度和容量都是orderLen,即5。

参考答案处写的有问题,
新切片范围是[low, high),新切片容量是max
正确写法
新切片范围是[low, high),新切片容量是max-low
如何找到这个错误

  • 章节:第一章 slice篇 热身环节问题三处
  • 页码:

您认为应该如何?
正确写法
新切片范围是[low, high),新切片容量是max-low
图片
Uploading image.png…
其他补充信息

@junjiezou1 junjiezou1 added the bug Something isn't working label Dec 20, 2023
@junjiezou1
Copy link
Author

Uploading qqqqqqqqqqqqq.jpg…

@RainbowMango
Copy link
Owner

感谢反馈~

请问你看的是第二版还是第一版?另外还望提供页码信息,谢谢。

章节:第一章 slice篇 热身环节问题三处

第二版题目如下,您的图片没有上传完成(理解),还没定位所反馈的问题位置。

关于下面函数的描述,正确的是?

func SliceExtend() {
	s := make([]int, 0, 10)
	s1 := append(s, 1, 2, 3)
	s2 := append(s1, 4)

	fmt.Println(&s1[0] == &s2[0])
}

单选:

  • A: append函数在操作切片s和s1时发生了扩容
  • B: 编译错误,不可以对切片元素取址
  • C: 函数输出 true
  • D: 函数输出 false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants