Skip to content
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

Order of conditions in Forever loop is wrong #294

Open
ScriptDevil opened this issue Jan 8, 2015 · 0 comments
Open

Order of conditions in Forever loop is wrong #294

ScriptDevil opened this issue Jan 8, 2015 · 0 comments

Comments

@ScriptDevil
Copy link

back-link: ch02/index.html#console-application

forever {
        // test for empty string 'QString("")'
        if(line.isEmpty()) { continue;   }

        // test for null string 'String()'
        if(line.isNull()) { break;   }
}

should in reality be

forever {
        // test for null string 'QString()'
        if(line.isNull()) { break;   }

        // test for empty string 'QString("")'
        if(line.isEmpty()) { continue;   }
}

since isEmpty returns true even when the string is null. Your version would lead to an infinite loop. Further it should be QString() and not String().

@ScriptDevil ScriptDevil changed the title Order of conditions in Forever loopis wrong Order of conditions in Forever loop is wrong Jan 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant