Enums and Switches - Peanut Butter and Jelly and Rye Bread

Channel:
Subscribers:
2,810
Published on ● Video Link: https://www.youtube.com/watch?v=93wRZk-BY-0



Duration: 13:30
195 views
6


The only real reason to use a switch (other than some optimization efforts) is to use them in conjunction with an enum. By doing so, the compiler can tell that you're missing an enum and give you a nice warning for it.

But in general switch statements suck since they use non-standard flow control (i.e. no curly braces) and people always forget the break statements on them.

I didn't mention it in the video, but if you do want to use switch statements and intentionally omit the break statement, look up the fallthrough attribute.