Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I quit swift repl without using ctrl-d?

I want to quit swift repl gracefully and not use ctrl-d to exit it.

For eg. python repl can be exited by typing exit(). Is there a similar way of quitting swift repl?

like image 244
Ankit Goel Avatar asked Jun 11 '15 09:06

Ankit Goel


People also ask

How do I exit REPL in Swift?

One can also exit REPL into LLDB with just : and, then later quit (or exit ) using the LLDB command directly. Addendum: The LLDB command c or continue can be used to return to the Swift REPL environment. You can also type Control-D into the LLDB prompt to get back to the Swift REPL.

How do I get out of REPL?

You can exit the REPL by typing Ctrl+D (pressing the Ctrl and D keys at the same time).

What is the command for quitting the REPL terminal?

To exit from the REPL terminal, press Ctrl + C twice or write . exit and press Enter.

How do you abruptly stop execution in the REPL?

You can just press ctrl-d (*nix) or ctrl-z (Windows) to exit the REPL.


1 Answers

This answer complements Ankit Goel's correct :quit answer to also (1) provide an understanding of why the : is needed and (2) other options besides :quit.

Swift REPL works in conjuction with the LLDB debugger.

: is a REPL escape prefix to execute an LLDB command. From within REPL, :help will list the available LLDB commands.

Any of the following will quit both Swift REPL and subsequently LLDB with a single command line.

:exit :quit :q 

One can also exit REPL into LLDB with just : and, then later quit (or exit) using the LLDB command directly.

sh$ swift   Welcome… 1> print(18 + 4)   22 2> : (lldb) print "hello"   (String) $R0 = "hello" (lldb) quit sh$ 

Addendum: The LLDB command c or continue can be used to return to the Swift REPL environment.

like image 74
l --marc l Avatar answered Sep 17 '22 13:09

l --marc l