func (expr *UnaryOpExpression) Value(device datalayer.Device) (cloudvar.CloudVarValue, error) { switch expr.operation { case NOT: val, err := expr.operand.Value(device) if err != nil { return nil, err } valBool, ok := val.(bool) if !ok { return nil, fmt.Errorf("NOT operand must evaluate to boolean") } return !valBool, nil case HAS: propExpr, ok := expr.operand.(*PropertyExpression) if !ok { return nil, fmt.Errorf("HAS operand must be a variable reference") } _, err := device.LookupVarDef(propExpr.property) return (err == nil), nil default: return false, fmt.Errorf("Unexpected unary operation") } }