Thursday 11th of March 2010
|
Pramuka |
|
|
|
Written by drs.suparmin
|
|
Rabu, 01 April 2009 22:45 |
|
As you may have noticed if statements can be rather bulky and can take a while to read through, this can be a particular pain when coming back to old code you haven't seen in a while. An alternative method is to use the switch statement to shorten the code, let’s convert the code from the previous example into a switch statement. In the example below we start out with the switch keyword declaring that it’s a switch statement, inside the brackets is the object we want to evaluate, the case line represents the possible value and the trace statement executes if the test is successful. Finally the break line indicates the end of each case.
Example As you may have noticed if statements can be rather bulky and can take a while to read through, this can be a particular pain when coming back to old code you haven't seen in a while. An alternative method is to use the switch statement to shorten the code, let’s convert the code from the previous example into a switch statement. In the example below we start out with the switch keyword declaring that it’s a switch statement, inside the brackets is the object we want to evaluate, the case line represents the possible value and the trace statement executes if the test is successful. Finally the break line indicates the end of each case. Example As you may have noticed if statements can be rather bulky and can take a while to read through, this can be a particular pain when coming back to old code you haven't seen in a while. An alternative method is to use the switch statement to shorten the code, let’s convert the code from the previous example into a switch statement. In the example below we start out with the switch keyword declaring that it’s a switch statement, inside the brackets is the object we want to evaluate, the case line represents the possible value and the trace statement executes if the test is successful. Finally the break line indicates the end of each case. Example
|
Kalendar
 |
March 2010 |
 |
|
Copyright SMAN 16 Makassar.
Dibuat oleh Admin Super Keren.