IsTrue tries to evaluate the underlying value the Pythonic-way: Returns TRUE in one the following cases: * int != 0 * uint != 0 * float != 0.0 * len(array/chan/map/slice/string) > 0 * bool == true * underlying value is a struct Otherwise returns always FALSE.
()
| 215 | // |
| 216 | // Otherwise returns always FALSE. |
| 217 | func (v *Value) IsTrue() bool { |
| 218 | switch v.getResolvedValue().Kind() { |
| 219 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
| 220 | return v.getResolvedValue().Int() != 0 |
| 221 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: |
| 222 | return v.getResolvedValue().Uint() != 0 |
| 223 | case reflect.Float32, reflect.Float64: |
| 224 | return v.getResolvedValue().Float() != 0 |
| 225 | case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String: |
| 226 | return v.getResolvedValue().Len() > 0 |
| 227 | case reflect.Bool: |
| 228 | return v.getResolvedValue().Bool() |
| 229 | case reflect.Struct: |
| 230 | return true // struct instance is always true |
| 231 | default: |
| 232 | logf("Value.IsTrue() not available for type: %s\n", v.getResolvedValue().Kind().String()) |
| 233 | return false |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | // Negate tries to negate the underlying value. It's mainly used for |
| 238 | // the NOT-operator and in conjunction with a call to |
no test coverage detected