Sobes.tech
Junior — Senior

What output will be obtained in example №14

livecode

Task condition

Let's consider two classes that hold references to each other, and see what messages appear in the console after the objects are deallocated.

class Alpha {
    var betaReference: Beta? = nil
    deinit { print("Alpha deinitialized") }
}

class Beta {
    var alphaReference = Alpha()
    deinit { print("Beta deinitialized") }
}

var betaInstance: Beta? = Beta()
betaInstance?.alphaReference.betaReference = betaInstance
betaInstance = nil

After executing the code, determine which lines will be printed to the console.