Commit 8884fabf authored by Rob Pike's avatar Rob Pike

reflect: improve documentation for DeepEqual regarding maps

Keys use ==; values use deep equality. Also remove the word 'member'.
Fixes #4258.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6812055
parent 465b9c35
...@@ -122,9 +122,11 @@ func deepValueEqual(v1, v2 Value, visited map[uintptr]*visit, depth int) (b bool ...@@ -122,9 +122,11 @@ func deepValueEqual(v1, v2 Value, visited map[uintptr]*visit, depth int) (b bool
panic("Not reached") panic("Not reached")
} }
// DeepEqual tests for deep equality. It uses normal == equality where possible // DeepEqual tests for deep equality. It uses normal == equality where
// but will scan members of arrays, slices, maps, and fields of structs. It correctly // possible but will scan elements of arrays, slices, maps, and fields of
// handles recursive types. Functions are equal only if they are both nil. // structs. In maps, keys are compared with == but elements use deep
// equality. DeepEqual correctly handles recursive types. Functions are equal
// only if they are both nil.
// An empty slice is not equal to a nil slice. // An empty slice is not equal to a nil slice.
func DeepEqual(a1, a2 interface{}) bool { func DeepEqual(a1, a2 interface{}) bool {
if a1 == nil || a2 == nil { if a1 == nil || a2 == nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment