Case objects vs Enumerations in Scala

One big difference is that Enumerations come with support for instantiating them from some name String. For example: object Currency extends Enumeration { val GBP = Value(“GBP”) val EUR = Value(“EUR”) //etc. } Then you can do: val ccy = Currency.withName(“EUR”) This is useful when wishing to persist enumerations (for example, to a database) or … Read more

tech