Enum

Enums (Enumerated types) are a special kind of class used to represent a fixed number of constant values.
Declare an enumerated type using the enum keyword:

   

Syntax:

enum <enum_name>{
   const1,const2,...,constN
}


   

Example:


enum seasons { spring, summer, fall, winter }

 

void main() {

  print(seasons.values);

  seasons favoriteSeason = seasons.summer;

  print(favoriteSeason);

}

 




[seasons.spring, seasons.summer, seasons.fall, seasons.winter]
seasons.summer