Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
"game.isWon() == false" instead of "!game.isWon()"
In the video Craig uses "!game.isWon()" in the while loop of the Hangman class.
I was wondering if using "game.isWon() == false" would also be correct? This code is obviously just a little bit longer but is there another reason why Craig's version should be used?
alastair cooper30,617 Points
In my experience they are functionally equivalent. The following stack overflow post sums up the arguments, but basically it is brevity vs readability https://stackoverflow.com/questions/11831881/if-boolean-false-vs-if-boolean
Personally i think x == false is easier to read, but most experienced programmers I know prefer the ! and see the former as a beginners habit. If the variables are conventionally named, ie isEmpty, isLastRound, etc, then they are equally readable either way