]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: reflect.Zero results are neither addressable nor settable
authorRobert Griesemer <gri@golang.org>
Tue, 3 Jul 2012 23:06:24 +0000 (16:06 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 3 Jul 2012 23:06:24 +0000 (16:06 -0700)
This could be deduced from "The Laws of Reflection" but it seems
worthwhile highlighting it.

R=r
CC=golang-dev
https://golang.org/cl/6350073

src/pkg/reflect/value.go

index 79476ad2298bc587ce72992aabc52f2fb61fe002..c44d408c6bc3c2e1d09b8b885d9c2681afcc0ea8 100644 (file)
@@ -1713,10 +1713,11 @@ func ValueOf(i interface{}) Value {
        return Value{typ, unsafe.Pointer(eface.word), fl}
 }
 
-// Zero returns a Value representing a zero value for the specified type.
+// Zero returns a Value representing the zero value for the specified type.
 // The result is different from the zero value of the Value struct,
 // which represents no value at all.
 // For example, Zero(TypeOf(42)) returns a Value with Kind Int and value 0.
+// The returned value is neither addressable nor settable.
 func Zero(typ Type) Value {
        if typ == nil {
                panic("reflect: Zero(nil)")