在throw参数周围加上括号是否有效?

编程入门 行业动态 更新时间:2024-10-27 18:30:53
本文介绍了在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参数周围加上括号是否有效?

本文发布于:2023-07-31 15:47:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1260071.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:括号   参数   throw

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!