how two pointers one by new and other by & on sturct are equal

168 views
Skip to first unread message

pradeep padala

unread,
Oct 3, 2015, 12:20:46 AM10/3/15
to golang-nuts
x := new(Bootcamp)
    fmt.Printf("%p\n", x)
    y := &Bootcamp{}
    fmt.Printf("%p\n", y)
    fmt.Println(*x == *y)

o/p
0x183104e0
0x18310500
true


Dustin

unread,
Oct 3, 2015, 12:49:06 AM10/3/15
to golang-nuts
Your dereferencing the pointer so its doing strict comparison

Dustin

unread,
Oct 3, 2015, 12:49:35 AM10/3/15
to golang-nuts
Typo struct not strict

C Banning

unread,
Oct 3, 2015, 6:27:50 AM10/3/15
to golang-nuts

Pradeep Padala

unread,
Oct 7, 2015, 2:57:39 PM10/7/15
to Dustin, golang-nuts

On Sat, Oct 3, 2015 at 10:19 AM, Dustin <djhe...@gmail.com> wrote:
struct not strict

understood,  

Thanks


regards,
pradeep

Reply all
Reply to author
Forward
0 new messages