gitlab.com/apertussolutions/u-root@v7.0.0+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  }