In Section 4 Lesson 15, there is an error in the suggested code for detecting duplicate users during the repair process #198
Replies: 2 comments 2 replies
-
Hello @kildren-coder, This should be reported in the |
Beta Was this translation helpful? Give feedback.
1 reply
-
report in the issue |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
At the end of the video, we need to provide suggestions for detecting duplicate users. The approach in the video is correct, but the code provided contains errors.
The code is as follows:
According to the given code, all players are checked after being added to the array and
addressToRaffleId[newPlayers[i]] = raffleId
is set. Then, checkingrequire(addressToRaffleId[newPlayers[i]] != raffleId, "PuppyRaffle: Duplicate player")
obviously leads to a situation where the require check cannot pass.We expect that before a player is added to the queue, their raffleId should be checked to see if it matches the raffleId of the current round. If it matches, it means they have already joined this round of the raffle and should not be added again.
Considering the impact of default values, the correct code should be as follows:
Beta Was this translation helpful? Give feedback.
All reactions