• 0 Posts
  • 29 Comments
Joined 1 year ago
cake
Cake day: June 10th, 2023

help-circle













  • I can understand telling you not to use break and continue if the point is to teach you to think about different ways to solve problems, but saying it’s because “it makes the code harder to read” is bullshit. Readable code flow is important, but if using those makes your code too hard to read, your problem is most likely that you’ve just written shitty code.

    To get really into the technical weeds, what break and continue boil down to in the compiled machine code is a non-conditional branch instruction. This is just going to move the execution pointer to a different location in memory. Other keywords, such as if, elif, and else, will compile down to conditional branch instructions. Basically the same thing, but they have the added cost of having to evaluate some data to see if the branch should happen at all. You can achieve the same things with both, but the high level code might need to look different.

    For instance, if you’re in a loop, continue will let you skip the rest of the code in the loop to get to the next iteration. Not a huge deal to instead make the entire code block conditional to skip it. However, the break keyword will let you exit the loop at any point, which is more complicated to deal with. You would have to conditionalize your code block and force the looping condition to something that would stop it on the next iteration. If you ask me, that has the potential to be much more complicated than necessary.

    Also, good luck using switch without any breaks, but I’m guessing that’s not quite what your teacher had in mind.

    In short, just go with it for now. Be creative and find a way to make it work to your teacher’s liking, but always try to be aware of different ways you can accomplish a task. Also, I don’t know what language you’re using, but if you’re in C/C++ or C# and you feel like getting really cheeky, it doesn’t sound like she disallowed the use of goto. It’s kinda like break with fewer safeguards, so it’s super easy to write broken code with it.


  • I can confirm from firsthand experience how miserable that is, having passed multiple kidney stones shaped like that. Doesn’t even need to be larger than a few millimeters in diameter to make you wish you were dead just to escape from hours torturous pain.



  • zib@kbin.socialtoAtheist Memes@lemmy.worldThis
    link
    fedilink
    arrow-up
    11
    ·
    1 year ago

    Also an atheist, but was recently in a church for a non-religious event. I got bored waiting for it to start, so I cracked up one of the bibles there to a random page. The first thing I saw was a passage about how if a man’s son is disobedient and doesn’t get his act together, the man is allowed to kill his son by stoning him to death. My immediate reaction was along the lines of “jfc they let kids read this shit?” You could make a wicked drinking game out of all the fucked up shit you can find in there.