docs.scala-lang icon indicating copy to clipboard operation
docs.scala-lang copied to clipboard

Clarify terminology for enums with parameters on the parent class

Open linteck opened this issue 4 years ago • 1 comments

In this page: https://docs.scala-lang.org/scala3/reference/enums/enums.html

Is this example of 'Parameterized enums' really a 'Parameterized enums'?

enum Color(val rgb: Int):
  case Red   extends Color(0xFF0000)
  case Green extends Color(0x00FF00)
  case Blue  extends Color(0x0000FF)

=================== This is my understanding. Maybe I am wrong. Parameterized enums should have parameters in enum value. Have parameters in the enum type is not 'Parameterized enums'.

This is a 'Parameterized enums':

enum Color(val rgb: Int):
  case Red (alfa: Double)   extends Color(0xFF0000)
  case Green (car: String)  extends Color(0x00FF00)
  case Blue  (bright: Double)  extends Color(0x0000FF)

linteck avatar Oct 27 '21 12:10 linteck

I agree we should clarify the terminology we use to describe enums where the parent class takes parameters (aka shared fields) vs enum cases that take parameters (unique fields per case).

bishabosha avatar Nov 01 '21 10:11 bishabosha