Follow

:C 

@amiloradovsky@functional.cafe guess you meant to omit the default case, cause I'm getting different output and no warnings.

Enumeration in general are not supposed to be type safe, their whole point is to be interchangeable and interoperable with integers, you are supposed to use them to index arrays or do arithmetic or bit twiddling. You can do something like this instead:
ix.io/2Il9/c
It's not perfect, but makes it harder to call the function with wrong parameters. They can't do it inattentively anymore, they have to study this mess, understand it, and then intentionally break the clear conventions, ignoring the crashing debug build.

· · SubwayTooter · 0 · 0 · 0
Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.