DeepEqual
Explain why the printed output is false?Modify line A to assure the printed output really equals to equality of the values of x and y.
package main
import (
"fmt"
)
type S struct {
a, b, c string
}
func main() {
x := interface{}(&S{"a", "b", "c"})
y := interface{}(&S{"a", "b", "c"})
fmt.Println(x == y) //A
}
Answer
package main
import (
"fmt"
"reflect"
)
type S struct {
a, b, c string
}
func main() {
x := interface{}(&S{"a", "b", "c"})
y := interface{}(&S{"a", "b", "c"})
fmt.Println(reflect.DeepEqual(x, y))
}