Documentation
¶
Overview ¶
Package equal provides a deep equivalence relation for arbitrary values. package equal
Example (Equal) ¶
//!+
fmt.Println(Equal([]int{1, 2, 3}, []int{1, 2, 3})) // "true"
fmt.Println(Equal([]string{"foo"}, []string{"bar"})) // "false"
fmt.Println(Equal([]string(nil), []string{})) // "true"
fmt.Println(Equal(map[string]int(nil), map[string]int{})) // "true"
//!-
Output: true false true true
Example (EqualCycle) ¶
//!+cycle
// Circular linked lists a -> b -> a and c -> c.
type link struct {
value string
tail *link
}
a, b, c := &link{value: "a"}, &link{value: "b"}, &link{value: "c"}
a.tail, b.tail, c.tail = b, a, c
fmt.Println(Equal(a, a)) // "true"
fmt.Println(Equal(b, b)) // "true"
fmt.Println(Equal(c, c)) // "true"
fmt.Println(Equal(a, b)) // "false"
fmt.Println(Equal(a, c)) // "false"
//!-cycle
Output: true true true false false
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Value ¶
Value is the interface to a dynamic value.
Hint: All implentations provide a New function, which takes two arguments - an initial default content - a go pointer variable (typially created by var ...) to hold and access the content
Note: All implentations should also provide a Let method which receives the represented type.
Click to show internal directories.
Click to hide internal directories.