Skip to content

Commit

Permalink
reflect: update CanAddr, CanSet documentation
Browse files Browse the repository at this point in the history
CanAddr was wrong, out of date; CanSet was incomplete.

R=r
CC=golang-dev
https://golang.org/cl/4442066
  • Loading branch information
rsc committed Apr 20, 2011
1 parent 7412583 commit 64787e3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/pkg/reflect/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,17 +395,16 @@ func (v Value) Bool() bool {
// CanAddr returns true if the value's address can be obtained with Addr.
// Such values are called addressable. A value is addressable if it is
// an element of a slice, an element of an addressable array,
// a field of an addressable struct, the result of dereferencing a pointer,
// or the result of a call to NewValue, MakeChan, MakeMap, or Zero.
// a field of an addressable struct, or the result of dereferencing a pointer.
// If CanAddr returns false, calling Addr will panic.
func (v Value) CanAddr() bool {
iv := v.internal()
return iv.flag&flagAddr != 0
}

// CanSet returns true if the value of v can be changed.
// Values obtained by the use of unexported struct fields
// can be read but not set.
// A Value can be changed only if it is addressable and was not
// obtained by the use of unexported struct fields.
// If CanSet returns false, calling Set or any type-specific
// setter (e.g., SetBool, SetInt64) will panic.
func (v Value) CanSet() bool {
Expand Down

0 comments on commit 64787e3

Please sign in to comment.