Switch Case

What is the point of switch-case exporessions?

I've never really understood the point of switch-case expressions. What is the benefit to using these over using if statements or hash tables?
Exporessions.. I know. I'm a little exporied today.

If statements and switch constructs are not interchangeable. You can use if to do everything that switch does. But not the reverse.
Switch statements present code in a better organized way. More importantly, they are more efficient. Since switch statements are created based on integers only, the compiler builds a jump table. When you have multiple cases and you can use switch, then use it.

Find Switch Case On eBay Below:

Recently Purchased Switch Case:

Bookmark the permalink.

Comments are closed.