]> Cypherpunks repositories - gostls13.git/commitdiff
slices: print modified cloned slice in ExampleClone
authorTobias Klauser <tklauser@distanz.ch>
Thu, 3 Oct 2024 15:23:22 +0000 (17:23 +0200)
committerGopher Robot <gobot@golang.org>
Thu, 3 Oct 2024 17:47:36 +0000 (17:47 +0000)
Make it obvious that numbers wasn't modified, but clone was.

Change-Id: Id8bd4ca59b7348cd218faef61abfdf12e20c89f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/617795
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/slices/example_test.go

index 305745e88305048f9eafe2199a4b2a05e4ead53b..f775b88f6b76ca24e0cb3edbbbf6569e6c6dee58 100644 (file)
@@ -325,9 +325,11 @@ func ExampleClone() {
        fmt.Println(clone)
        clone[2] = 10
        fmt.Println(numbers)
+       fmt.Println(clone)
        // Output:
        // [0 42 -10 8]
        // [0 42 -10 8]
+       // [0 42 10 8]
 }
 
 func ExampleGrow() {