1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

repl: treat =x at the start of a new line, the same as println(x)

This commit is contained in:
Delyan Angelov 2020-05-24 14:16:38 +03:00
parent c4fbae3edc
commit 465dc685cc

View File

@ -178,6 +178,9 @@ fn run_repl(workdir string, vrepl_prefix string) {
// Save the source only if the user is printing something,
// but don't add this print call to the `lines` array,
// so that it doesn't get called during the next print.
if r.line.starts_with('='){
r.line = 'println(' + r.line[1..] + ')'
}
if r.line.starts_with('print') {
source_code := r.current_source_code(false) + '\n${r.line}\n'
os.write_file(file, source_code)