Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@mngr break; is actually not discouraged anywhere AFAIK. Think of it: a for-loop where you go through all indexes of an array, knowing that one index contains a value you need, but you don't know the exact index and value. As soon as you find it, you can just exit the whole loop instead of wasting processing power.
-
mngr9407y@filthyranter yea, you are right, break is used, but not at his full spaghetting potential, if you know what i mean
-
Radioh967y@filthyranter my teacher told me it didn't look great when I did that for that exact reason. He much preferred a while loop with a boolean value set to true. And when found it would set the value to false and stop the while loop. I guess people have their own opinions on how code should look.
Date a programmer. We break loops, not hearts.
joke/meme