-Today, I tried to handle conditional branching: switch statement.
A switch statement is the execution of one of many options.
If there are some conditional branches in the "switch statement", you can write more clearly than in the "if statement".
It can also be used to compare whether the right and left sides are equal.
To write a conditional branch, write "switch (variable you want to judge) {case value you want to branch: processing break;}" like this.
Write the variable "group" you want to judge in "()", and then in "{} (block)"
In "case", write the value you want to branch by the variable of "group", close it with ": (colon)", and close it. Write the processing when "group" is "pirate".
Keep in mind that the ": (colon)" after the "case" is not the "; (semicolon)" you always write.
Also, be aware that you often forget to write "break;".
In the case of some conditional branches like this, you can use the "switch statement" to describe it more clearly than the "if statement".
27th, why not ... (laughs)
――――――――――――――――――――――――――――――――――――――――――――――――――
** Study method ** Watch a programming video that explains carefully. ↓ to imitate.
The video is practical and easy to understand.
Well then, thank you for your hard work today.
Recommended Posts