When is a do-while appropriate?

后端 未结 13 1764
Happy的楠姐
Happy的楠姐 2020-11-30 09:15

When is a do-while the better choice over other types of loops? What are some common scenarios where its better than others?

I understand the function of a do-while,

13条回答
  •  离开以前
    2020-11-30 09:32

    When it is more appropriate to do something and then evaluate the boolean expression...or as Brian said...when you need something done at least once. This syntax moves the evaluation of the boolean expression to after the loop instead of before the loop.

提交回复
热议问题