0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

switch文

Last updated at Posted at 2021-04-03

用途

  • ある式や値が複数の値を取りうる
  • それぞれの値に応じて処理を変えたい
  • 式と値が一致した処理を実行する

#構文

switch {
    case 値1:
        //式の結果が値1と等しいときに実行する処理
        break;
    case 値2:
        //式の結果が値2と等しいときに実行する処理
        break;
    case 値3:
        //式の結果が値3と等しいときに実行する処理
        break;
    default:
        //式の結果がどれにも該当しないときの処理
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?