Define the following complex object hierarchy below into a playground in XCode:
class Foo {
var name: String
required init(name: String) {
self.name = name
}
}
class Bar: Foo {
}
class Baz: Bar {
}
Creating instances of these classes yields confusing results:
var foo = Foo(name: "Hello") // renders as {name: "Hello"}
var bar = Bar(name: "Hello") // renders as {{name: "Hello"}}
var baz = Baz(name: "Hello") // renders as {{{...}}}
The results make it appear that the bar
and baz
are objects composed of instances of their parents, rather than inheriting from them.
Is this just the way XCode renders these objects, or is their structure not as I would expect?