How do you write code whose logic is protected against future additional enumerations?

后端 未结 10 1580
旧巷少年郎
旧巷少年郎 2021-02-05 08:01

I\'m having a hard time describing this problem. Maybe that\'s why I\'m having a hard time finding a good solution (the words just aren\'t cooperating). Let me explain via cod

10条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 08:49

    You cannot hold two pieces of data in one data store. You need to store two pieces of data, and therefore an enum is the wrong data type for this. These should be instances of a Fruit class.

提交回复
热议问题