Update objects.md (#401)
This commit is contained in:
parent
7108e9c50d
commit
2edd39e0c3
1 changed files with 3 additions and 1 deletions
|
@ -297,9 +297,11 @@ to add `StringArray` to the script:
|
|||
```golang
|
||||
// script that uses 'my_list'
|
||||
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"}}
|
||||
s.Add("my_list", myList) // add StringArray value 'my_list'
|
||||
s.Run() // prints "one, two, three"
|
||||
|
|
Loading…
Reference in a new issue