github.com/elves/elvish@v0.15.0/pkg/eval/vars/blackhole.go (about)

     1  package vars
     2  
     3  type blackhole struct{}
     4  
     5  func (blackhole) Set(interface{}) error {
     6  	return nil
     7  }
     8  
     9  func (blackhole) Get() interface{} {
    10  	return nil
    11  }
    12  
    13  // NewBlackhole returns a blackhole variable. Assignments to a blackhole
    14  // variable will be discarded, and getting a blackhole variable always returns
    15  // nil.
    16  func NewBlackhole() Var {
    17  	return blackhole{}
    18  }
    19  
    20  // IsBlackhole returns whether the variable is a blackhole variable.
    21  func IsBlackhole(v Var) bool {
    22  	_, ok := v.(blackhole)
    23  	return ok
    24  }