-
Notifications
You must be signed in to change notification settings - Fork 22.8k
Uses a non const variable to illustrate the assignment in equality check #40442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Preview URLs (comment last updated: 2025-07-19 11:23:43) |
``` | ||
|
||
the test would always return `true`, causing the program to report that the game has been won. Be careful! | ||
the test would always return `true`, causing the program to `setGameOver()` after the first wrong guess. Be careful! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong; it would throw an error instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Josh-Cena for reviewing. I am unable to reproduce the error (FF 128). Could you please share the message/screenshot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to change const guessCount
to let guessCount
? Because that's not reflected in your PR. If you don't change that (I would prefer if you don't), then this line would throw an error instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file references the code from here which has let guessCount
already. userGuess
is const
and that's why I've not used it to illustrate the issue. Hope this works. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I see what you are doing. That's a really good approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. Thanks for working on this!
Description
The assignment check used a
const
variable. Changed to one that usedlet
Motivation
Additional details
Thanks @Goal-max for reporting
Related issues and pull requests
Fixes #39332