在throw参数周围加上括号是否有效? [英] Does adding parentheses around a throw argument have any effect?

查看:153
本文介绍了在throw参数周围加上括号是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

写作上有区别吗?

throw SomeException;

throw(SomeException);

我已经看到一些消息源声称由于某种原因,后者(带括号)不是一个好选择

I have seen some sources that claim the latter (with parentheses) is not a good option for some reason but alas I can not recall where I've seen this.

推荐答案

应该不要除括号外,两个表达式之间的功能差异。我从未听说过任何明确的理由说明为什么一个人应该优于另一个人。

There should not be any functionality difference between the two expressions apart from the parentheses. I have never heard of any clear reason that says why one should be superior to the other.

对我来说,第一个选项看起来更直观,因为它不包含不必要的括号。 !

To me the first option looks more intuitive as it does not include the unnecessary parentheses!

也如@Pubby在评论中所述,不要与需要括号的throw说明符混淆( throw 可能 已弃用)。

Also as @Pubby said in the comment, one should not confuse with the throw specifier which requires parentheses (throw specifier is probably deprecated).

这篇关于在throw参数周围加上括号是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆