[英]How to reset the Swift REPL?
在你提到在类中使用Swift REPL之后,我想也许你会对这样一个肮脏的技巧感到满意:
$ while true; do swift; done
Welcome to Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.30). Type :help for assistance.
1> let x = 1
x: Int = 1
2> x
$R0: Int = 1
3> :q
Welcome to Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.30). Type :help for assistance.
1> x
repl.swift:1:1: error: use of unresolved identifier 'x'
x
^
1> :q
Welcome to Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.30). Type :help for assistance.
1> ^D
^C
$
通过快速按^D
(EOF;终止REPL)然后^C
(终止循环)可以完全退出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.