I have an array of custom class objects and I need to modify a property of the last element. I know "last" and "first" are implemented as getters, however, that doesn't help me :) Is there another way than accessing the last element by index?
UPDATE
protocol DogProtocol {
var age: Int {get set}
}
class Dog: DogProtocol {
var age = 0
}
var dogs = Array<DogProtocol>()
dogs.append(Dog())
dogs.last?.age += 1 // Generates error in playground: left side of mutating operator isn't mutable: 'last" is a get-only property