Go: make use of multiple return values

This commit is contained in:
2018-10-10 20:59:35 +02:00
parent 2717cd569b
commit 2fe3c4753f
3 changed files with 136 additions and 168 deletions

View File

@@ -53,9 +53,7 @@ func main() {
for i := 2; i < len(os.Args); i++ {
args = append(args, *ell.NewString(os.Args[i]))
}
var result []ell.V
if !L.EvalBlock(program, args, &result) {
if _, ok := L.EvalBlock(program, args); !ok {
fmt.Printf("%s: %s\n", "runtime error", L.Error)
}
}

View File

@@ -29,8 +29,7 @@ import (
)
func run(L *ell.Ell, program []ell.V) {
var result []ell.V
if !L.EvalBlock(program, nil, &result) {
if result, ok := L.EvalBlock(program, nil); !ok {
fmt.Printf("\x1b[31m%s: %s\x1b[0m\n", "runtime error", L.Error)
L.Error = ""
} else {