]> Cypherpunks repositories - gostls13.git/commitdiff
reflect.DeepEqual: document that empty and nil are unequal for slices
authorRob Pike <r@golang.org>
Wed, 26 Sep 2012 05:21:07 +0000 (15:21 +1000)
committerRob Pike <r@golang.org>
Wed, 26 Sep 2012 05:21:07 +0000 (15:21 +1000)
Update #4133.
Added a sentence of documentation to call out the behavior.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6572051

src/pkg/reflect/deepequal.go

index c12e90f36ccc229b5ad29d6bcabcf70ce1060442..8ca20750a9443e4619a92deed2d121927b1b631c 100644 (file)
@@ -125,6 +125,7 @@ func deepValueEqual(v1, v2 Value, visited map[uintptr]*visit, depth int) (b bool
 // DeepEqual tests for deep equality. It uses normal == equality where possible
 // but will scan members of arrays, slices, maps, and fields of structs. It correctly
 // handles recursive types. Functions are equal only if they are both nil.
+// Note: unlike regular ==, DeepEqual distinguishes an empty slice from a nil slice.
 func DeepEqual(a1, a2 interface{}) bool {
        if a1 == nil || a2 == nil {
                return a1 == a2