3 ms·
The proceeding lines make that clearer for me. In my mind a switch statement is like "here is an execution path for every state this enumeration can hold" (lik
by s_m_t 7y ago
The proceeding lines make that clearer for me.
In my mind a switch statement is like "here is an execution path for every state this enumeration can hold" (like the author says, compiler or ide may warn you about missing cases) while an if else is a bit more general than that. With an if else you might only be checking for a few specific conditions.