https://wiki.beyondunreal.com/w/index.php?action=history&feed=atomSwitch statement - Revision history2017-11-18T03:04:12ZRevision history for this page on the wikiMediaWiki 1.25.1https://wiki.beyondunreal.com/Switch_statement?diff=46236&oldid=prevSeriousBarbie: +break not possible inside an if block2015-10-15T22:54:21Z<p>+break not possible inside an if block</p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:54, 15 October 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="L18" >Line 18:</td>
<td colspan="2" class="diff-lineno">Line 18:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Then the engine checks all '''case''' labels in the order they occur. Case expressions must have the same result type as the switch expression. If a case expression evaluates to the same value as the switch expression, the case's code is executed, otherwise the next case expression is checked. The default label must be the last case in the switch block, but can be omitted.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Then the engine checks all '''case''' labels in the order they occur. Case expressions must have the same result type as the switch expression. If a case expression evaluates to the same value as the switch expression, the case's code is executed, otherwise the next case expression is checked. The default label must be the last case in the switch block, but can be omitted.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>You can use the '''break''' statement to exit the switch block at any given point. Execution will continue at the first statement after the closing curly brace of the switch block.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>You can use the '''break''' statement to exit the switch block at any given point <ins class="diffchange diffchange-inline">except inside an ''if'' block</ins>. Execution will continue at the first statement after the closing curly brace of the switch block.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''Note:''' By default code execution will "fall through" to the next case if you don't use a '''break''' statement. When execution falls though, the case expression is still evaluated, but its result is ignored. Putting a '''break''' as the last statement on the last case is optional.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''Note:''' By default code execution will "fall through" to the next case if you don't use a '''break''' statement. When execution falls though, the case expression is still evaluated, but its result is ignored. Putting a '''break''' as the last statement on the last case is optional.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{navbox unrealscript}}</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{navbox unrealscript}}</div></td></tr>
</table>SeriousBarbiehttps://wiki.beyondunreal.com/Switch_statement?diff=33109&oldid=prevWormbo: New page: The '''switch''' statement is used to conditionally execute code, much like the If statement. ==Syntax== The general syntax of the switch statement is as follows: '''switch ('''''exp...2008-10-10T07:30:24Z<p>New page: The '''switch''' statement is used to conditionally execute code, much like the <a href="/If_statement" title="If statement">If statement</a>. ==Syntax== The general syntax of the switch statement is as follows: '''switch ('''''exp...</p>
<p><b>New page</b></p><div>The '''switch''' statement is used to conditionally execute code, much like the [[If statement]].<br />
<br />
==Syntax==<br />
The general syntax of the switch statement is as follows:<br />
'''switch ('''''expression''''') {'''<br />
'''case''' ''expression''''':'''<br />
...<br />
'''break;'''<br />
<br />
'''case''' ''expression''''':'''<br />
...<br />
<br />
'''default:'''<br />
...<br />
'''}'''<br />
<br />
When code execution reaches a '''switch''' statement, it first evaluates the expression in parentheses after the "switch" keyword. Unlike the '''If''' statement's condition, this expression does not have to evaluate to a value of type ''bool'', but can be of any supported UnrealScript [[type]].<br />
Then the engine checks all '''case''' labels in the order they occur. Case expressions must have the same result type as the switch expression. If a case expression evaluates to the same value as the switch expression, the case's code is executed, otherwise the next case expression is checked. The default label must be the last case in the switch block, but can be omitted.<br />
<br />
You can use the '''break''' statement to exit the switch block at any given point. Execution will continue at the first statement after the closing curly brace of the switch block.<br />
<br />
'''Note:''' By default code execution will "fall through" to the next case if you don't use a '''break''' statement. When execution falls though, the case expression is still evaluated, but its result is ignored. Putting a '''break''' as the last statement on the last case is optional.<br />
<br />
{{navbox unrealscript}}</div>Wormbo