3 ms·
It's not confusing if you understand that r is pointer that points to something and b is that pointer, which is nil. So of course r (the variable containing a
by cratermoon 6y ago
It's not confusing if you understand that r is pointer that points to something and b is that pointer, which is nil. So of course r (the variable containing a pointer) isn't nil, b (the pointer) is nil, and r is the pointer b.
- Dylan16807 6y agoPointers don't normally compare equal to the thing they're pointing to. If it's acting as a proxy it's confusing the specific way that some things get proxied and other things don't.
- catlifeonmars 6y agoAgree, r == b in this example is confusing because in all other instances, the interface{} is a kind of box type. That box type is implicitly unwrapped in the r == b comparison. Although more verbose, I’d be happy with having to do something like this for comparison: b2, ok := r.(*bytes.Buffer) equal := ok && b2 == b
- cratermoon 6y agolaughs in C