How to use enum with grouping and subgrouping hierarchy/nesting

前端 未结 3 1413
一向
一向 2021-02-04 00:32

I have one enum \'class\' called Example as follows:

enum Example {
//enums belonging to group A:
   enumA1,
   enumA2,
   enumA3,
//en         


        
3条回答
  •  隐瞒了意图╮
    2021-02-04 01:04

    Small addition:

    I do like both answers from @ELEVATE and @Wendel. And it depends (as always) on the scenario when to use which solution. If each entry must be part of a single group I prefer ELEVATE's solution, because it forces me to add this single group. However if only some enum need to be grouped or they are not distinct I go with Wendel's solution, because it is more flexible (but more error prone)

提交回复
热议问题