Can you have boolean expressions,if statements...in a switch for each case? and what are legal names for the different cases like case 1, case 2... can u use variables instead of numbers?
Can you have boolean expressions,if statements...in a switch for each case? and what are legal names for the different cases like case 1, case 2... can u use variables instead of numbers?
>Can you have boolean expressions
Yes, but most compilers will give a warning about this because the switch expression must be an integral value. This can be fixed by assigning the return value of an expression to a variable and using that as the switch variable.
>if statements...in a switch for each case?
No, an if statement is not an expression. You can use the ternary operator though, provided it returns an integral value.
>and what are legal names for the different cases like case 1,
>case 2... can u use variables instead of numbers?
Anything that is a valid constant such as '1', 'b', 45, 12. You cannot use variables since they aren't constant values.
-Prelude
My best code is written with the delete key.