Update objects.md (#401)

This commit is contained in:
skelly 2023-01-29 22:43:17 -08:00 committed by GitHub
parent 7108e9c50d
commit 2edd39e0c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -297,9 +297,11 @@ to add `StringArray` to the script:
```golang ```golang
// script that uses 'my_list' // script that uses 'my_list'
s := tengo.NewScript([]byte(` s := tengo.NewScript([]byte(`
print(my_list + "three") fmt := import("fmt")
fmt.println(my_list, ", three")
`)) `))
s.SetImports(stdlib.GetModuleMap("fmt"))
myList := &StringArray{Value: []string{"one", "two"}} myList := &StringArray{Value: []string{"one", "two"}}
s.Add("my_list", myList) // add StringArray value 'my_list' s.Add("my_list", myList) // add StringArray value 'my_list'
s.Run() // prints "one, two, three" s.Run() // prints "one, two, three"