Hello and happy new year.

I'm re-reading the Go Language Specification, and 
at https://golang.org/ref/spec#Variables I found this example:

  var x interface{} // x is nil and has static type interface{}
  var v *T               // v has value nil, static type *T
  x = 42                 // x has value 42 and dynamic type int
  x = v                   // x has value (*T)(nil) and dynamic type *T

Since the first comment is different for the others (`x is nil` against `x 
has value`) I decided to run a simple test
https://play.golang.org/p/QAX92NQDqO4.  It has an additional entry:
  var z *interface{}


The output of the first and last line is

x is nil and has static type interface{}
<invalid reflect.Value> <nil>

z is nil and has static type *interface{}
<nil> *interface {}


The question is: why reflect.Type.String() returns `<nil>` instead of  
`interface{}` ?
Is the example printing the static or the dynamic type?


Thanks
Manlio Perillo

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1b6bb8b9-5537-457f-b41d-a97afe474f08%40googlegroups.com.

Reply via email to