I\'d like to create a color object based on an Int
. I can achieve the same result using sealed class
and enum
and was wondering if one
A sealed
class is "an extension of enum classes". They can exist in multiple instances that contain state while each enum constant exists only as a single instance.
Since, in your example, you don't need the values to be instantiated multiple times and they don't provide special behavior, enums should just be right for the use case.
Also, see the docs.