MCPcopy Create free account
hub / github.com/d5/tengo / Call

Method Call

vm_test.go:2296–2319  ·  view source on GitHub ↗
(
	args ...tengo.Object,
)

Source from the content-addressed store, hash-verified

2294}
2295
2296func (o *StringArray) Call(
2297 args ...tengo.Object,
2298) (ret tengo.Object, err error) {
2299 if len(args) != 1 {
2300 return nil, tengo.ErrWrongNumArguments
2301 }
2302
2303 s1, ok := tengo.ToString(args[0])
2304 if !ok {
2305 return nil, tengo.ErrInvalidArgumentType{
2306 Name: "first",
2307 Expected: "string(compatible)",
2308 Found: args[0].TypeName(),
2309 }
2310 }
2311
2312 for i, v := range o.Value {
2313 if v == s1 {
2314 return &tengo.Int{Value: int64(i)}, nil
2315 }
2316 }
2317
2318 return tengo.UndefinedValue, nil
2319}
2320
2321func (o *StringArray) CanCall() bool {
2322 return true

Callers

nothing calls this directly

Calls 1

TypeNameMethod · 0.65

Tested by

no test coverage detected