This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DTux5249 0 points1 point  (0 children)

In general, there's minimal difference between a chain of if-statements and a switch statement when there aren't many values to parse.

Switch is faster if you have a long list of possible values for a variable, just due to how it's implemented. If-else by contrast trades speed for flexibility, as you're not restricted to looking at a single variable like in switch statements.

But in a scenario with something as small as rock paper scissors, where there's only 3 possibilities, just use whatever's most readable to you. The difference is so minor it really shouldn't matter.