I'm looping through an array of basketball players where their id is equal to a certain player's id. Then i want to add +1 to the fouls
property of the player object.
self.match.matchState.homePlayers.first{$0.id == toPlayer.id}?.fouls += 1
I have the error
Left side of mutating operator isn't mutable: function call returns immutable value
The fouls
property is an optional integer. var fouls: int?
Even when i changed the Player
struct to a class type i have another error.
Cannot pass immutable value as inout argument: function call returns immutable value
So how am i supposed to loop in an array of objects and change a certain property in it?