was broken because Players contains RacingPlayerInfo structs, which is a value type, not a reference type. This means that var playerInfo = ... results in a local copy of the data. The following line then only modifies this local copy, leaving Players unchanged.
This new code creates a local copy of the data, modifies it, and then updates the struct stored in the Players list.
The previous code
was broken because
Players
containsRacingPlayerInfo
structs, which is a value type, not a reference type. This means thatvar playerInfo = ...
results in a local copy of the data. The following line then only modifies this local copy, leavingPlayers
unchanged.This new code creates a local copy of the data, modifies it, and then updates the struct stored in the
Players
list.