Should I prefer sealed class or Enumeration in Scala?

后端 未结 2 2041
盖世英雄少女心
盖世英雄少女心 2021-01-02 02:13

I\'m trying to implement a Plurk API biding for Scala, but I have a design choice to made.

For example, the gender attribute of a Plurk user could be one of \"male\"

2条回答
  •  时光取名叫无心
    2021-01-02 02:37

    If you don't need to iterate over your objects of Gender or need methods like next and previous, classes and objects is the right solution.

    If you need the features of the "classes and objects" and of "scala.Enumeration" this and this question could be of interest to you.

提交回复
热议问题