mardi 11 février 2020

How to list all objects in a Scala object?

So, I have defined several objects in my_object. I'm able to make import my_package._ and access them all, or I can do import my_package.{Obj1, Obj2}.

I want to list them all and get their names. I can do val my_list = List(Obj1, Obj2).map(_.toString()), but listing them manually is a no-go.

How could I produce my_list without declaring the objects individually?





Aucun commentaire:

Enregistrer un commentaire