Switch Statement |
|
Switch Statement SyntaxA switch statement is used to execute a block of Fractal Science Kit fractal program statements based on the value of an integer expression. This is frequently used with enums defined in the properties section. The syntax of the switch statement is: switch (<IntegerExpression>) { The value of the integer expression is matched against each of the integer constants given in the case statements. If a match is found, the associated block of statements is executed. Otherwise, the block of statements associated with the (optional) case else statement is executed. Each case statement includes a comma (,) separated list of 1 or more integer constants. These constants are typically enums defined in the properties section of the program, but they can also be const values defined in the global section, literal numbers, or an expression that evaluates to a literal number. Each of the integer constants given in the case statements must be greater than or equal to 0 and less than 1024. Example: z = Polar(Sample.TrapValue, Sample.TrapAngleRaw) This example uses an option called SolidMapProjection to determine how to project the point z onto the complex plane. Example: switch (Triangle) { This example sets ang to a radian angle based on the option Triangle. Example: switch (Triangle) { This example is equivalent to the previous example but uses statement separator character (:) to join the case statement with its associated block (a single statement) on the same line for readability. |
Copyright © 2004-2019 Ross Hilbert |