This project is read-only.


Enum is a special kind of Mirelle type. It allows you to restrict a variable to a given set of possible values, saved as identifiers. Consider the following code:

enum action

var act = action:add 

Now you can be 100% sure that the act variable will only contain one of the four possible values.
Identifiers can be separated by spaces or newlines, or possibly with a comma.

Enum restrictions

  • An enum and a casual type with the same name cannot coexist for obvious reasons
  • Enum cannot contain identifiers to_a and to_s because they are reserved for special purposes
  • Enums cannot be used as child or parent types

Special methods

The enum types are given two special methods:
  • string to_s: gets the string name of the current item in format "enum:value"
  • static T[] to_a: gets an array with all possible items of the enum

Last edited May 1, 2011 at 3:38 PM by impworks, version 3


No comments yet.