What is lldb_expr in Swift Playground?

I was trying to show basic inheritance to someone and how the super initializer is always called by default when overriding 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 am I getting {__lldb_expr_380.Animal feet 4}

the last line? It disappears when I create an instance variable under the animal class.

+3


source to share


1 answer


I'm not 100% about it, but it seems reasonable and logical to me.

Your class is Animal

empty, so the compiler needs a way to express / print the values โ€‹โ€‹of the class / it. So what it does is print __lldb_expr_380.Animal

, because the compiler doesn't know what else to do. If you add a property, for example legs

, the result will be as follows: {{legs 2} feet 4}

.



So, in my understanding, whenever you have this empty superclass, the compiler will be "confused" and the error that will happen is that it will just print out __llb_expr_:some_number:.ClassName

instead of something like {}

.

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

+3


source







All Articles