15
Switchケース:1つの数字の代わりに範囲を使用できますか
スイッチを使いたいのですが、ケースが多いのですが、近道はありますか?これまでのところ、私が知って試した唯一の解決策は次のとおりです。 switch (number) { case 1: something; break; case 2: other thing; break; ... case 9: .........; break; } 私ができることを望んでいるのは、次のようなものです。 switch (number) { case (1 to 4): do the same for all of them; break; case (5 to 9): again, same thing for these numbers; break; }