Lecture 38 Challenge

In the previous lecture, you mention that the do while loop generates a warning about not all control paths return a value.
Instead of using

while (Status != EGuessStatus::OK);

I simply changed it to

while (true);

which doesn’t generate the warning, at least for me. Eventually, once the user does enter a valid guess, it does exit the loop and return from the method.

My question is, does this mean that ignorance is bliss? Since it’s not being tied to EGuessStatus in the while condition, the compiler doesn’t seem to even see that “not all control paths return a value.”

My second question is, would this be a valid way to write this logic considering it doesn’t generate a warning? Or should I get into the practice of solution in the video anyway?

Hi Drew,

I think part of the reason to write this out long form is in applying what Ben always says about being explicit and deliberate with every line you write.

I’d be interested to see more experienced users weigh in on instances where not being explicit here may cause trouble down the line?

Privacy & Terms