The following code does not work. Although it is correctly compiled, there is a runtime error on the “self.age = newAge” statement and I don’t know why.
It takes a relatively long time before crasching with a lot of messages “Person.age.setter” in the left panel (more than 260 000 !). Then the program ended with exit code: 9
// Person.swift
struct Person {
var name = "Ruben"
var age : Int {
get { return self.age }
set(newAge) { self.age = newAge }
}
}
// Main.swift
var myPerson = Person()
myPerson.age = 24