Jump to content

Switch statement ​​​​​​​​​​​​​​?


Recommended Posts

  • Bot

Hello, I have a doubt. I saw several codes in which the cases of the switch statement have keys {}.
So my question is: When do I know that keys should be put or not?
For example, in "if statement" must be set keys if the content of the "if" has more than one line.
Does the same thing happen with the cases?
Excuse my bad English.

english_banner.gif

Link to comment
Share on other sites

  • Bronze

No need for { }. Case actually tell the program where to start code execution and is executed until the end of the switch or break;

If you make a new case and place all the code you want inside { } and in the end you don't write break, the code will be executed after { } even if it is another case.

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.