Consider the following example class:
class SocketWrapper {
let sock: Int32
init() throws {
try sock = SocketWrapper.createSocket()
}
deinit {
close(sock)
}
}
What happens if createSocket() throws and the init() therefore fails? sock would be left uninitialized. Is deinit still called (on an partially uninitialized object) when init() throws?