Anon5710
(Kevin Deckx)
1
Hello,
Came across something that I find to be very weird:
I have created a minimal example : goplayground
Why is the interface seen as not nil in test1?
I taught that “interface{}” can be interpreted as “map[string]interface{}” ?
Whats the logic behind this?
mje
(Jeff Emanuel)
2
It’s not nil in test1
because a
is of not type interface{}
, so one is created to “wrap” a
.
A variable of an interface type can hold a value of a type that implements the interface .
I tweaked your playground here to unwrap itf
in test1
Go Playground - The Go Programming Language
savvdm
(Dmitry Savvateev)
3
Interface can hold a nil value, being itself not nil: A Tour of Go
Go Playground - The Go Programming Language
system
(system)
Closed
4
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.