mattn / anko

Scriptable interpreter written in golang
http://play-anko.appspot.com/
MIT License
1.45k stars 120 forks source link

question: extending slices and getting data out #342

Closed SandyWalsh closed 3 years ago

SandyWalsh commented 3 years ago

Sorry for the n00b questions ... been having fun playing with this library.

I'm doing this

        type Foo {
               Things []string
        }

        ptrs := []*Foo{}
    err = ev.Define("foo", ptrs)
    if err != nil {
        return nil, err
    }

    _, err = vm.Execute(ev, nil, script)
    if err != nil {
        return nil, err
    }

    outi, err := ev.Get("foo")
    if err != nil {
        return nil, err
    }

and in my script I'm (effectively) doing

    foo[0].Things = foo[0].Things + "new thing"

But I'm not seeing "new thing" coming out. Should I be using some sort of append()-like call?

Also, the Execute() call has a return value ... what's in it? And how do I set it? Don't see anything in the docs about it.

SandyWalsh commented 3 years ago

nm ... figured it out.