From 35163ab8c96e4475154493dc9922c29ab7554c46 Mon Sep 17 00:00:00 2001 From: MH Rohman Masyhar Date: Thu, 25 Oct 2018 09:03:36 +0700 Subject: [PATCH] Update 8-fungsi-copy.go The builtin copy(dst, src) copies min(len(dst), len(src)) elements. So if your dst is one, only one element will be copied. https://golang.org/ref/spec#Appending_and_copying_slices ``` The number of elements copied is the minimum of len(src) and len(dst). ``` --- chapter-A.15/8-fungsi-copy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter-A.15/8-fungsi-copy.go b/chapter-A.15/8-fungsi-copy.go index 656cb0c7c..605ba9804 100644 --- a/chapter-A.15/8-fungsi-copy.go +++ b/chapter-A.15/8-fungsi-copy.go @@ -8,7 +8,7 @@ func main() { var copiedElemen = copy(fruits, aFruits) - fmt.Println(fruits) // ["apple", "watermelon", "pinnaple"] + fmt.Println(fruits) // ["watermelon"] fmt.Println(aFruits) // ["watermelon", "pinnaple"] fmt.Println(copiedElemen) // 1 }