From a021d742499d94ce783295cf03dd9e59dc5e5891 Mon Sep 17 00:00:00 2001 From: skiy Date: Fri, 23 Oct 2015 15:36:23 +0800 Subject: [PATCH 1/3] Update 07.2.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 勘误 --- eBook/07.2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eBook/07.2.md b/eBook/07.2.md index 7ba6557..c9c47c4 100644 --- a/eBook/07.2.md +++ b/eBook/07.2.md @@ -226,7 +226,7 @@ v := make([]int, 10, 50) 这样分配一个有 50 个 int 值的数组,并且创建了一个长度为 10,容量为 50 的 切片 v,该 切片 指向数组的前 10 个元素。 **问题 7.3** 给定 `s := make([]byte, 5)`,len(s) 和 cap(s) 分别是多少?`s = s[2:4]`,len(s) 和 cap(s) 又分别是多少? -**问题 7.4** 假设 `s1 := []byte{'p', 'o', 'e', 'm'}` 且 `s2 := d[2:]`,s2 的值是多少?如果我们执行 `s2[1] == 't'`,s1 和 s2 现在的值又分配是多少? +**问题 7.4** 假设 `s1 := []byte{'p', 'o', 'e', 'm'}` 且 `s2 := s1[2:]`,s2 的值是多少?如果我们执行 `s2[1] = 't'`,s1 和 s2 现在的值又分配是多少? ## 7.2.5 多维 切片 From a0e6514a5f0eb0f0ed9db72763715026402bb2e2 Mon Sep 17 00:00:00 2001 From: skiy Date: Fri, 23 Oct 2015 17:57:16 +0800 Subject: [PATCH 2/3] Update 07.5.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文字错误 --- eBook/07.5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eBook/07.5.md b/eBook/07.5.md index 5014788..92d9a19 100644 --- a/eBook/07.5.md +++ b/eBook/07.5.md @@ -44,7 +44,7 @@ func AppendByte(slice []byte, data ...byte) []byte { } ``` -`func copy(dst, src []T) int` copy 方法将类型为 T 的切片从源地址 src 拷贝到目标地址 dst,覆盖 dst 的相关元素,并且返回拷贝的元素个数。源地址和目标地址可能会有重叠。拷贝个数是 src 和 dst 的长度最小值。如果 src 是字符串那么元素类型就是 byte。如果你还想继续使用 src,在拷贝技术后执行 `src = dst`。 +`func copy(dst, src []T) int` copy 方法将类型为 T 的切片从源地址 src 拷贝到目标地址 dst,覆盖 dst 的相关元素,并且返回拷贝的元素个数。源地址和目标地址可能会有重叠。拷贝个数是 src 和 dst 的长度最小值。如果 src 是字符串那么元素类型就是 byte。如果你还想继续使用 src,在拷贝结束后执行 `src = dst`。 **练习 7.9** From aa3618337c5cb09b556b76a071beb13d5d7ce13a Mon Sep 17 00:00:00 2001 From: skiy Date: Sat, 24 Oct 2015 09:03:40 +0800 Subject: [PATCH 3/3] Update 07.2.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文字错误 --- eBook/07.2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eBook/07.2.md b/eBook/07.2.md index c9c47c4..3ef315d 100644 --- a/eBook/07.2.md +++ b/eBook/07.2.md @@ -226,7 +226,7 @@ v := make([]int, 10, 50) 这样分配一个有 50 个 int 值的数组,并且创建了一个长度为 10,容量为 50 的 切片 v,该 切片 指向数组的前 10 个元素。 **问题 7.3** 给定 `s := make([]byte, 5)`,len(s) 和 cap(s) 分别是多少?`s = s[2:4]`,len(s) 和 cap(s) 又分别是多少? -**问题 7.4** 假设 `s1 := []byte{'p', 'o', 'e', 'm'}` 且 `s2 := s1[2:]`,s2 的值是多少?如果我们执行 `s2[1] = 't'`,s1 和 s2 现在的值又分配是多少? +**问题 7.4** 假设 `s1 := []byte{'p', 'o', 'e', 'm'}` 且 `s2 := s1[2:]`,s2 的值是多少?如果我们执行 `s2[1] = 't'`,s1 和 s2 现在的值又分别是多少? ## 7.2.5 多维 切片