Swift object to reference itself (without optionals) -


i trying create object class contain reference self or object:

class myobject  {     let owner: myobject      init(owner: myobject) {         self.owner = owner;     } }  class rootobject : myobject {     init() {         self.owner = self     } }  var root = rootobject() var child = myobject(root)  // child.owner == root // child.owner.owner == root 

is possible modify code , implement idea without use of optionals?


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -