When is a do-while appropriate?

后端 未结 13 1804
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:38

    It's appropriate when you would like to have your condition checked at the end of the loop execution. Hence the loop will always run at least once and then it will verify if it should iterate further.

提交回复
热议问题