How to avoid using Enums?

前端 未结 5 664

Until asking a question on here I never considered (enums) to be a \"bad thing.\" For those out there that consider them not to be best practice, what are some approachs/p

5条回答
  •  甜味超标
    2020-12-14 21:52

    I think using an enum is a good thing. It provides strong type safety.

    They have some disadvantages at times, but this is really typically related to situations where every possible option is not known in advance. If you have a fixed set of options, such as your example, then strong typed enums are a good thing, and should not be avoided.

提交回复
热议问题