Return Guess VS while( condition )

Hi guys~
This is my first post, I hope this is a good question.
As the instructor coded the “do while” loop, the while had a condition of " while (Status != EGuessStatus::OK)".
I was wondering if this “while” comparator is necessary, because we are already intended to loop until we hit the “return Guess” line to exit the function altogether.

If that’s the case, just doing a while(true) until we hit the “return Guess” should also work, is that correct?
I ran the code like that and it seemed ok, but I wanted to make sure if I’m missing anything.


1 Like

Yes it’s ok to use while(true) in this case. Note that this eliminates the need to put the Status variable declaration outside the loop. Also note that the behavior would change if BCGame.CheckGuessValidity() could return Invalid_Status for some reason.

Privacy & Terms