last returns the last element, but it does not allow you to set a new value. In fact, the property implements only get :
/// The last element, or `nil` if the array is empty var last: T? { get }
Therefore, you cannot use it to modify an array.
Note that in case the returned item is a composite value type (i.e., a structure, such as an array or a dictionary), a copy of the actual item stored in the array is returned. Therefore, any change made to the element returned by last or any of its properties and data is performed only for this copy, without affecting the original array.
source share