What does this array-of-classes code print? Copy-on-Write
Task
class Human {
var name: String
init(name: String) { self.name = name }
}
let man = Human(name: "Artem")
let woman = Human(name: "Dasha")
let family = [man, woman]
let anotherFamily = family
anotherFamily.last?.name = "Vika"
print(family.last?.name)
What prints? How would you make it print Dasha? What is copy-on-write and which types have it? Does CoW work for every struct?
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep