Skip to content

Commit

Permalink
save last v in global for REPL (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
vt128 authored Dec 26, 2024
1 parent c05ff20 commit 8dfa5b9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions repl/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func rep(opts *syntax.FileOptions, rl *readline.Instance, thread *starlark.Threa
return nil
}

// store the result in "_" variable to hold the value of last expression, similar to Python REPL
globals["_"] = v

// print
if v != starlark.None {
fmt.Println(v)
Expand Down

0 comments on commit 8dfa5b9

Please sign in to comment.