Hacker News new | ask | show | jobs
by lpribis 288 days ago
> How do you implement do while loops?

    loop {
        ...body
        if (condition)
            break;
    }
2 comments

What is the benefit over this:

    loop: {
        ...body
        if (!conditon)
            goto loop;
    }
What separates loop syntax from goto is explicit syntax for the condition. When you give that up, why do you have loop at all?
Shouldn't your body be after the condition check?

Otherwise you get one iteration even if your condition was false to begin with?

I specifically asked for a do while loop.
Oh wow. My brain entirely ignored the second do in that sentence.