AnsweredAssumed Answered

Whats better Case or If

Question asked by grinch on Apr 5, 2010
Latest reply on Apr 6, 2010 by comment_1

Title

Whats better Case or If

Post

Although they can be used interchangeably what is better to use with a long list of conditionals If statement of Case statements?

 

For Example:

 

If x = 1 or x = 3 or x = 5 or x = 7  Do thing a

If x = 2 or x = 4 or x = 6 or x = 8 Do thing b

 

Or

Case

x = 1 do thing a

x = 2 do thing b

x = 3 do thing a

x = 4 do thing b

x = 5 do thing a

x = 6 do thing b

x = 7 do thing a

x = 8 do thing b

 

Both achieve the same result, but other then the case statement being more readable, is there other advantages or disadvantages of either method?

 

Thanks

Chris

 

Outcomes