返回和break语句的区别语句、区别、break

2023-09-05 07:11:04 作者:鹤

如何做一个返回语句从破发语句的不同? 如果我必须退出一个if条件,其中一个我应该preFER,返回破发

How does a return statement differ from break statement?. If I have to exit an if condition, which one should I prefer, return or break?

推荐答案

突破被使用,而返回用于回它被称为或步骤停止进一步执行。

break is used when you want to exit from loop, while return is used to go back to the step where it was called or to stop further execution.