Reputation: 734
Here is what I am trying todo
for _,p := range *players {
for _,tp := range *tournamentPlayers{
if p.Id==tp.PlayerId {
p.Points += tp.Prize
}
}
}
after for nothing is saved
Upvotes: 0
Views: 262
Reputation: 4411
When you range
over an array, the second variable will be a copy of the value. So when you're modifying it, you don't actually modify the value stored in the array.
You need to use the index:
for i := range *players {
for _,tp := range *tournamentPlayers{
if players[i].Id==tp.PlayerId {
players[i].Points += tp.Prize
}
}
}
You'll find more informations in the spec.
Upvotes: 4