Should I prefer sealed class or Enumeration in Scala?

后端 未结 2 2050
盖世英雄少女心
盖世英雄少女心 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:33

    Using Enumeration is also quite a bit cheaper in terms of class count. In the Gender example that does not matter, but it might start to matter if you want to model processor instructions by an enumeration with 100+ elements.

提交回复
热议问题