在切换中缩进大小写的首选方式是什么? [英] What is the preferred way to indent cases in a switch?

查看:91
本文介绍了在切换中缩进大小写的首选方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Eclipse中编写另一个开关时,我再次遇到了一个相当奇怪的(至少对我来说)默认缩进,该缩进应用于'switch'语句:

As I was writing another switch in Eclipse, I once again came across a rather weird (to me, at least) default indentation, which is applied to 'switch' statements:

switch (i) {
case 1:
    ...
case n:
    ...
}

我倾向于另一种方式:

switch (i) {
    case 1:
        ...
    case n:
        ...
}

哪种方式对您更具可读性和令人赏心悦目?我仍然没有百分百地确定最适合我的,所以我想坚持最适合其他会读取我的代码的人.

Which way is more readable and eye-pleasing for you? I'm still not hundred percent determined what's best for me, so I'd like to stick to what's best for other people who would read my code.

顺便说一句,如果这太主观的话,您可以随意关闭这个问题. :)

BTW, you're free to close this question if this is too subjective. :)

推荐答案

我也喜欢第二种方法.但是,保持一致在特定应用程序和/或特定团队中的重要性比缩进一种或另一种方式更为重要.

I prefer the second way as well. But it is more important to stay consistent within a particular application and/or within a particular team than it is to indent one way or the other.

这篇关于在切换中缩进大小写的首选方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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