mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
25 lines
494 B
Go
25 lines
494 B
Go
package vars
|
|
|
|
type blackhole struct{}
|
|
|
|
func (blackhole) Set(interface{}) error {
|
|
return nil
|
|
}
|
|
|
|
func (blackhole) Get() interface{} {
|
|
return nil
|
|
}
|
|
|
|
// NewBlackhole returns a blackhole variable. Assignments to a blackhole
|
|
// variable will be discarded, and getting a blackhole variable always returns
|
|
// nil.
|
|
func NewBlackhole() Var {
|
|
return blackhole{}
|
|
}
|
|
|
|
// IsBlackhole returns whether the variable is a blackhole variable.
|
|
func IsBlackhole(v Var) bool {
|
|
_, ok := v.(blackhole)
|
|
return ok
|
|
}
|