Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
988 views
in Technique[技术] by (71.8m points)

ios - What is lldb_expr in Swift Playground?

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()

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I am not 100% about this but to me this seems sane and logical.

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}.

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 {}.

Reference: http://discuss.codewithchris.com/t/episode-7-classes-error---lldb-expr-/150


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...