Post

Replies

Boosts

Views

Activity

Reply to What does "#if DEBUG" really mean in Swift?
Even in C, regular if statements are often a better choice. In an if-else chain like the following, if selMethod is a constant value, then the compiler will omit the unused parts (thanks to standard constant-folding and dead-code-elimination optimizations). Plus you have the option of making selMethod be variable in the future: static const int selMethod = 4; if (selMethod == 0) { ... method 0 ... } else if (selMethod == 1) { ... method 1 ... } else if (selMethod == 2) { ... method 2 ... } else { abort("Invalid selMethod"); }
Apr ’22