MCPcopy Index your code
hub / github.com/expr-lang/expr / ExampleAsBool

Function ExampleAsBool

expr_test.go:267–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

265}
266
267func ExampleAsBool() {
268 env := map[string]int{
269 "foo": 0,
270 }
271
272 program, err := expr.Compile("foo >= 0", expr.Env(env), expr.AsBool())
273 if err != nil {
274 fmt.Printf("%v", err)
275 return
276 }
277
278 output, err := expr.Run(program, env)
279 if err != nil {
280 fmt.Printf("%v", err)
281 return
282 }
283
284 fmt.Printf("%v", output.(bool))
285
286 // Output: true
287}
288
289func ExampleAsBool_error() {
290 env := map[string]any{

Callers

nothing calls this directly

Calls 5

CompileFunction · 0.92
EnvStruct · 0.92
AsBoolFunction · 0.92
RunFunction · 0.92
PrintfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…