You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functions := map[string]govaluate.ExpressionFunction {
"strlen": func(args ...interface{}) (interface{}, error) {
length := len(args[0].(string))
return (float64)(length), nil
},
}
expString := "strlen('someReallyLongInputString') <= 16"
expression, _ := govaluate.NewEvaluableExpressionWithFunctions(expString, functions)
result, _ := expression.Evaluate(nil)
// result is now "false", the boolean value
why does the non-functional expression version handle the type-casting into a number type, while the functional version needs us to explicitly typecast our returned value into a float64? it fails and gives me a comparator/modifier error when i remove the explicit float64() typecasting.
why does the non-functional expression version handle the type-casting into a number type, while the functional version needs us to explicitly typecast our returned value into a float64? it fails and gives me a comparator/modifier error when i remove the explicit float64() typecasting.
Returns:
Value '123' cannot be used with the comparator '>=', it is not a number
The text was updated successfully, but these errors were encountered: