How to access objects within an object by mixing in a trait with reflection?

前端 未结 3 1932
遇见更好的自我
遇见更好的自我 2020-12-11 07:28

How can I get all of the objects within an object with reflection?

Consider this code:

object MonthDay extends MyEnum {
  //Some important holidays
          


        
3条回答
  •  时光说笑
    2020-12-11 07:58

    You should be able to use the pre-existing Scala Enumeration class: http://www.scala-lang.org/api/current/scala/Enumeration.html

    It seems to come very close to your use-case!

提交回复
热议问题