We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我在leecode上写代码的时候注意到有return的写法比没有return的快,有没有大佬了解这其中的道理,不写return的这条规范是处于什么目的?
The text was updated successfully, but these errors were encountered:
leetcode 上面那个测试时间比较玄学,你多测试几次结果不一样。而且你这个个例并不能说明 有 return比没return 快,具体还得分析具体代码被编译器如何优化,和有没有return 关系应该不大。
规范里建议在半路返回的时候加 return,而最终表达式默认返回多值则无需加return,这是为了在比较复杂的逻辑中增强可读性。半路返回的值因为添加了return而比较显眼。
Sorry, something went wrong.
No branches or pull requests
我在leecode上写代码的时候注意到有return的写法比没有return的快,有没有大佬了解这其中的道理,不写return的这条规范是处于什么目的?
The text was updated successfully, but these errors were encountered: