github.com/elves/elvish@v0.15.0/pkg/eval/vals/bool.go (about) 1 package vals 2 3 // Booler wraps the Bool method. 4 type Booler interface { 5 // Bool computes the truth value of the receiver. 6 Bool() bool 7 } 8 9 // Bool converts a value to bool. It is implemented for nil, the builtin bool 10 // type, and types implementing the Booler interface. For all other values, it 11 // returns true. 12 func Bool(v interface{}) bool { 13 switch v := v.(type) { 14 case nil: 15 return false 16 case bool: 17 return v 18 case Booler: 19 return v.Bool() 20 } 21 return true 22 }