Re:Golang concepts from an OOP point of view
by patates on Tuesday September 13, 2016 @07:29AM
(#12487088)
Wow, that seems like a big issue. Is this accepted as a bug and being worked on or yet another feature?
[ Parent
| on HN ]
Re:Golang concepts from an OOP point of view
by weberc2 on Tuesday September 13, 2016 @11:31AM
(#12489133)
It's not a bug. Interfaces are reference types. In this case, the interface is implemented by a pointer type. The interface can be thought of as a pointer to a nil pointer, but the "interface pointer" itself is not nil.
This is a tricky concept until you learn that interfaces are reference types.
Here's a simplified version of the previous example that illustrates this concept: https://play.golang.org/p/pODBgaHXq5