What can be converted to switch blocks and what can't
switch blocks are not universal silver bullets, stop treating them like one. Use
switch only when you are matching an expression against a discrete set of possible values using
== only (must be constant in GMS 1.x and above), optionally plus a catch-all case.
In other words, only code in the following
if-else ladder form have an equivalent
switch block (final
else optional):
Code:
var value = expression;
if (value == constant1) {
//val1
}
else if (value == constant2) {
//val2
}
//...
else {
//default
}
Any code that cannot fit this form should not be written using
switch blocks.