作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
使用 Swift REPL 时,每次我为变量赋值时,它都会显示该值的整个转储。我想抑制这一点,因为当它是一个大型结构的实例时,它会完全破坏前面的行。
1 > let a = SomethingComplex()
a: SomethingComplex = {
list = 3 values {
[0] = {
edges = 4 values {
[0] = {
id = 1
from = 0x0000000100506110 {
edges = 4 values {
[0] = {
id = 3
from = 0x0000000100506a50 {
edges = 4 values {
[0] = {
id = 5
from = 0x0000000100506820 {...}
to = 0x0000000100506a50 {...}
}
.
.
.
有没有办法抑制这种情况?
最佳答案
Swift REPL 在 lldb 调试器的上下文中运行,默认情况下,打印表达式中声明的变量的值。这是由 lldb 变量控制的
print-decls -- If true, LLDB will print the values of variables declared in an expression. Currently only supported in the REPL (default: true).
(在 Swift REPL 中使用 :set list
获取所有 lldb 变量的列表。)
所以你可以抑制变量声明的输出通过将该变量设置为 false
。示例(请注意,前导冒号用于发出 lldb 命令):
$ swiftWelcome to Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.39.1). Type :help for assistance. 1> struct SomethingComplex { let x = 1; let y = 2 } 2> let a = SomethingComplex()a: SomethingComplex = { x = 1 y = 2} 3> :set set print-decls false 3> let b = SomethingComplex() 4>
关于swift - 在 Swift REPL 中抑制值转储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49655668/
我正在为我的应用程序使用 Tank-Auth。我唯一的问题是激活和重置帐户密码。 用于登录、注册、注销;我对这些代码没有问题; $route['login'] = "/auth/login"; $ro
我是一名优秀的程序员,十分优秀!