By Alvin Alexander. Last updated: January 22, 2021
As a brief note to self, a Scala 3 enum
is already sealed, so you never need to write sealed enum
.
The Scala 3 docs demonstrate this. They state that an enum
is “used to define a type consisting of a set of named values.” Then they share this example:
enum Color:
case Red, Green, Blue
Finally they state, “This defines a new sealed class, Color
, with three values, Color.Red
, Color.Green
, Color.Blue
. The color values are members of Colors
companion object.”
So again, a Scala 3 enum is already sealed. (I’m sure this probably shows up as an error in an IDE if you try to use sealed enum
, but I’m not using an IDE atm.)