什么是Swift Playground中的lldb_expr? [英] What is lldb_expr in Swift Playground?
问题描述
我试图向某人演示基本继承以及如何在覆盖init时默认调用超级初始化器:
I was trying to demonstrate basic inheritance to someone and how the super initializer is always called by default when overriding an init:
class Animal{
init(){
println("Animal has been initialized!")
}
}
class Dog:Animal{
var feet:Int = 4
override init(){
println("Dog has been initialized!")
}
}
var d = Dog()
为什么我得到 {__ lldb_expr_380.Animal feet 4}
?当我在动物类下创建一个实例变量时,它就消失了。
Why is it that I get {__lldb_expr_380.Animal feet 4}
on the last line? It goes away when I create an instance variable under the animal class.
推荐答案
我不是100%关于此,而是对我而言看起来很健全。
I am not 100% about this but to me this seems sane and logical.
你的 Animal
类是空的,所以编译器需要一种表达/打印类的方法/它的价值观。所以它的作用是打印 __ lldb_expr_380.Animal
,因为编译器不知道还有什么可以做。如果添加属性,例如 legs
,结果将变为: {{legs 2} feet 4}
。
Your Animal
class is empty so the compiler needs a way to express / print the class / it's values. So what it does is print __lldb_expr_380.Animal
because the compiler doesn't know what else to make of it. If you add a property, for example legs
, the result becomes this: {{legs 2} feet 4}
.
所以,根据我的理解,只要你有这个空的超类,编译器就会混淆,发生的错误就是打印出来 __ llb_expr_:some_number:.ClassName
而不是 {}
。
So, in my understanding whenever you have this empty superclass the compiler will get 'confused' and the error that happens is that it will just print out __llb_expr_:some_number:.ClassName
instead of something like {}
.
参考: http://discuss.codewithchris.com / t / episode-7-classes-error --- lldb-expr- / 150
这篇关于什么是Swift Playground中的lldb_expr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!