elvish/pkg/eval/vars/blackhole.go

25 lines
478 B
Go
Raw Normal View History

2018-02-15 16:59:49 +08:00
package vars
type blackhole struct{}
func (blackhole) Set(any) error {
return nil
}
func (blackhole) Get() any {
2019-04-20 02:44:11 +08:00
return nil
}
// NewBlackhole returns a blackhole variable. Assignments to a blackhole
// variable will be discarded, and getting a blackhole variable always returns
2020-09-05 05:45:04 +08:00
// nil.
2018-03-08 21:20:31 +08:00
func NewBlackhole() Var {
return blackhole{}
}
// IsBlackhole returns whether the variable is a blackhole variable.
2018-03-08 21:20:31 +08:00
func IsBlackhole(v Var) bool {
_, ok := v.(blackhole)
return ok
}