Created
October 20, 2014 05:54
-
-
Save 3846masa/6218a252ea5b75385552 to your computer and use it in GitHub Desktop.
if文の中が1行のとき,どれがベストなのか
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
if文の中が1行のとき,どれがベストなのか | |
コメント募集(下記以外の方法でも可) | |
*/ | |
// 01 | |
if (true) println("true"); | |
// 02 | |
if (true) | |
println("true"); | |
// 03 | |
if (true){println("true");} | |
// 04 | |
if (true){ | |
println("true"); | |
} | |
// 05 | |
if (true) | |
{ | |
println("true"); | |
} |
スコープ絡んでくると,囲むほうが無難な気もしてきますね....
なるほど,参考になります!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ちなみに C++ の場合には変数スコープの話も絡んできて括弧ありとなしではまるで意味が違うので、できれば1行も複数行も統一して置いた方が良いと思います。