MCPcopy
hub / github.com/expr-lang/expr / ExampleAsFloat64

Function ExampleAsFloat64

expr_test.go:341–357  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

339}
340
341func ExampleAsFloat64() {
342 program, err := expr.Compile("42", expr.AsFloat64())
343 if err != nil {
344 fmt.Printf("%v", err)
345 return
346 }
347
348 output, err := expr.Run(program, nil)
349 if err != nil {
350 fmt.Printf("%v", err)
351 return
352 }
353
354 fmt.Printf("%v", output.(float64))
355
356 // Output: 42
357}
358
359func ExampleAsFloat64_error() {
360 _, err := expr.Compile(`!!true`, expr.AsFloat64())

Callers

nothing calls this directly

Calls 4

CompileFunction · 0.92
AsFloat64Function · 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…