Skip to content

Instantly share code, notes, and snippets.

@shabib87
Last active March 10, 2017 19:12
Show Gist options
  • Save shabib87/851506d65f9ff92b9d711bd972672185 to your computer and use it in GitHub Desktop.
Save shabib87/851506d65f9ff92b9d711bd972672185 to your computer and use it in GitHub Desktop.
In support to blog post
class Person {
let name: String
init(name: String) {
self.name = name
}
deinit {
print("\(name) is being deinitialized")
}
}
class Apartment {
let number: Int
init(number: Int) {
self.number = number
}
deinit {
print("Apartment \(number) is being deinitialized")
}
}
var person: Person? = Person(name: "John Doe")
person = nil
var apartment: Apartment? = Apartment(number: 123)
apartment = nil
// output:
// John Doe is being deinitialized
// Apartment 123 is being deinitialized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment