Pump the color

Report a typo

We have enum of colors. For some logs, it is necessary to get the color code, which is the name of the color in lowercase. The colors will be updated in the future, so using pattern matching will not be very convenient.

Modify the Color so that you can get the code without knowing the specific type of this color:

val color: Color = Color.Red

println(color.code) // red

val color2: Color = Color.Blue

println(color2.code) // blue

Sample Input 1:

Color.Red

Sample Output 1:

red
Write a program in Scala 3
enum Color:
case Red, Blue, Green, White
___

Create a free account to access the full topic