Question about early returns

Hello everyone! just to make sure, does an early return stop the program reading code further if the check is passed? For example, in the lecture does the code keep checking if you have less than 0 lives even if the word didn’t have the correct amount of letters?
Thanks!

A return statement exits the function.

void foo(bool cool)
{
    if (cool)
    {
        return;
    }
    // code here is never ran if cool == true
    // do some uncool stuff
}
2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms