github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/cmds/core/elvish/eval/vars/any.go (about) 1 package vars 2 3 type any struct { 4 ptr *interface{} 5 } 6 7 func (v any) Set(val interface{}) error { 8 *v.ptr = val 9 return nil 10 } 11 12 func (v any) Get() interface{} { 13 return *v.ptr 14 } 15 16 // NewAnyWithInit creates a variable with an initial value. The variable created 17 // can be assigned values of any type. 18 func NewAnyWithInit(v interface{}) Var { 19 return any{&v} 20 }