写作上有区别吗?
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参数周围加上括号是否有效?
发布评论