Comment on Real quick question about the "break"

crashfrog@lemm.ee ⁨7⁩ ⁨months⁩ ago

I suspect “you’ll fail the test if you use break” is more of a joke by your teacher than an actual grading rubric, although if you used it more than twice in the same test I wouldn’t award you better than a B.

Is there a benefit to not using breaks or continues?

The benefit is that you learn to write non-branching code. That’s important for beginners, who tend to write very complicated and complex code with lots of branching, which they then discover they’re not able to test and debug. Barring you from using break and continue forces you to write more abstract code to achieve the same level of function with less complexity, and that’s how programmers advance in skill - simpler, more abstract code.

Ultimately it’s an effort to kick a crutch out from under you. Whether you think that’s appropriate for a teacher is up to you, I guess - I’m inclined to think it is, but many students don’t respond well to being challenged.

source
Sort:hotnewtop