]> Cypherpunks repositories - gostls13.git/commit
reflect: improve documentation of IsNil
authorRob Pike <r@golang.org>
Wed, 19 Feb 2014 06:33:59 +0000 (22:33 -0800)
committerRob Pike <r@golang.org>
Wed, 19 Feb 2014 06:33:59 +0000 (22:33 -0800)
commit8b0b994c08c540702fbfe84a50ed72b93892d7c5
treedee623823332319f2b9e0ea5cc0da9a11f59c9a1
parent964f6d3ec4c6e2bed377878bd2862767bfae463d
reflect: improve documentation of IsNil
IsNil isn't quite the same as == nil, as this snippet shows:

// http://play.golang.org/p/huomslDZgw
package main

import "fmt"
import "reflect"

func main() {
        var i interface{}
        v := reflect.ValueOf(i)
        fmt.Println(v.IsValid(), i == nil)
        fmt.Println(v.IsNil())
}

The fact that IsNil panics if you call it with an untyped nil
was not apparent. Verbiage added for clarity.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/65480043
src/pkg/reflect/value.go