开发者

Why it is unsafe to use continue statament?

开发者 https://www.devze.com 2023-01-27 01:49 出处:网络
Can any one tell why it is not preferable to use conti开发者_如何学Gonue; statement in php coding?I dont see a \"real\" reason not to use it, but I can imagine, that loops can get a little bit confusi

Can any one tell why it is not preferable to use conti开发者_如何学Gonue; statement in php coding?


I dont see a "real" reason not to use it, but I can imagine, that loops can get a little bit confusing, if they are big and complex. Imagine if you see such a loop and dont realize the continue-keyword. Now you would expect, that the loop will get executed to the end every iteration. Especially if you use continue with the optional argument this can get really awkward.


I am not aware of any general reason not to use continue. It is a perfectly fine language construct.

If you have a source saying continue is bad, please add it to your question for discussion.


Some see break and continue as a "goto in disguise". Using these language constructs are perfectly valid. If you don't feel comfortable using them, don't.

0

精彩评论

暂无评论...
验证码 换一张
取 消