Created
March 17, 2014 19:56
-
-
Save yifan-gu/9606979 to your computer and use it in GitHub Desktop.
== in golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type obj struct { | |
a int | |
} | |
func main() { | |
o1 := &obj{1} | |
o2 := &obj{2} | |
o3 := &obj{1} | |
fmt.Println(o1 == o1) | |
fmt.Println(o1 == o2) | |
fmt.Println(o1 == o3) | |
m := make(map[int]*obj) | |
m[1] = o1 | |
a := m[1] | |
fmt.Println(&a, &o1) | |
fmt.Println(a == o1) | |
fmt.Println(a == o3) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
result:
true
false
false
0xc210000038 0xc210000018
true
false