Is it generally better/faster to do:
if (condition) return a
else if (condition2) return b
else return c
or
if (condition) return a
if (condition2) return b
return c
They both do the same thing but I am curious if there are other ramifications that need to be kept in mind when comparing these two snippets
Since there is always the same amount of code executed, it won’t make any difference. In terms of readability of the code I strongly suggest to use the “else” version. In this version you directly see (because of the “else”) that the first condition is not true in order to execute the else if branch. In the second example you could miss the “return” when reading and be confused why the code checks for several conditions.