Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whats wrong with switch and why if`? #29

Open
iegik opened this issue Dec 11, 2017 · 0 comments
Open

Whats wrong with switch and why if`? #29

iegik opened this issue Dec 11, 2017 · 0 comments
Labels

Comments

@iegik
Copy link

iegik commented Dec 11, 2017

Use the if statement when:

  • There are no more than two discrete values for which to test.
  • There are a large number of values that can be easily separated into ranges.

Use the switch statement when:

  • There are more than two but fewer than 10 discrete values for which to test.
  • There are no ranges for conditions because the values are nonlinear.

Use array lookup when:

  • There are more than 10 values for which to test.
  • The results of the conditions are single values rather than a number of actions to be taken.

@duluca duluca added the question label Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants