MCPcopy Create free account
hub / github.com/expr-lang/expr / Len

Function Len

builtin/lib.go:14–24  ·  view source on GitHub ↗
(x any)

Source from the content-addressed store, hash-verified

12)
13
14func Len(x any) any {
15 v := reflect.ValueOf(x)
16 switch v.Kind() {
17 case reflect.Array, reflect.Slice, reflect.Map:
18 return v.Len()
19 case reflect.String:
20 return utf8.RuneCountInString(v.String())
21 default:
22 panic(fmt.Sprintf("invalid argument for len (type %T)", x))
23 }
24}
25
26func Type(arg any) any {
27 if arg == nil {

Callers

nothing calls this directly

Calls 3

SprintfMethod · 0.80
StringMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected