in scala
class Enumeration

abstract class Enumeration
extends java.lang.Object
with scala.ScalaObject

The class Enumeration provides the same functionality as the enum construct found in C-like languages like C++ or Java. Here is an example:

 object Main extends Application {

   object WeekDays extends Enumeration  {
     val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
   }

   def isWorkingDay(d: WeekDays.Value) =
     ! (d == WeekDays.Sat || d == WeekDays.Sun)
 
   WeekDays filter (isWorkingDay) foreach { d => Console.println(d) }
 }
 
Parameters:
initial - the initial integer value associated with the first element
Parameters:
names - the sequence of element names of the enumeration
Author:
Matthias Zenger
Version:
1.0, 10/02/04

Class Summary
protected class Val

abstract class Value



Constructor Summary
def this

def this (initial: scala.Int, names: java.lang.String*)

def this (names: java.lang.String*)



Var Summary
protected var nextId : scala.Int

protected var nextName : scala.Iterator[java.lang.String]



Def Summary
final protected def Value (i: scala.Int) : Enumeration.this.Value

final protected def Value (i: scala.Int, name: java.lang.String) : Enumeration.this.Value

final protected def Value (name: java.lang.String) : Enumeration.this.Value

final protected def Value : Enumeration.this.Value

final def apply (x: scala.Int) : Enumeration.this.Value
Returns the enumeration value for the given id.
final def elements : scala.Iterator[Enumeration.this.Value]
Returns all values of this enumeration.
def exists (p: (Enumeration.this.Value) => scala.Boolean) : scala.Boolean

def filter (p: (Enumeration.this.Value) => scala.Boolean) : scala.Iterator[Enumeration.this.Value]

def flatMap [b] (f: (Enumeration.this.Value) => scala.Iterator[b]) : scala.Iterator[b]

def forall (p: (Enumeration.this.Value) => scala.Boolean) : scala.Boolean

def foreach (f: (Enumeration.this.Value) => scala.Unit) : scala.Unit

def map [b] (f: (Enumeration.this.Value) => b) : scala.Iterator[b]

final def maxId : scala.Int

def name : java.lang.String

override def toString : java.lang.String



Constructor Detail
def this

def this (initial: scala.Int, names: java.lang.String*)

def this (names: java.lang.String*)

Var Detail
protected var nextId : scala.Int

protected var nextName : scala.Iterator[java.lang.String]

Def Detail
final protected def Value (i: scala.Int): Enumeration.this.Value

final protected def Value (i: scala.Int, name: java.lang.String): Enumeration.this.Value

final protected def Value (name: java.lang.String): Enumeration.this.Value

final protected def Value : Enumeration.this.Value

final def apply (x: scala.Int): Enumeration.this.Value
Returns the enumeration value for the given id.

final def elements : scala.Iterator[Enumeration.this.Value]
Returns all values of this enumeration.

def exists (p: (Enumeration.this.Value) => scala.Boolean): scala.Boolean

def filter (p: (Enumeration.this.Value) => scala.Boolean): scala.Iterator[Enumeration.this.Value]

def flatMap [b](f: (Enumeration.this.Value) => scala.Iterator[b]): scala.Iterator[b]

def forall (p: (Enumeration.this.Value) => scala.Boolean): scala.Boolean

def foreach (f: (Enumeration.this.Value) => scala.Unit): scala.Unit

def map [b](f: (Enumeration.this.Value) => b): scala.Iterator[b]

final def maxId : scala.Int

def name : java.lang.String

override def toString : java.lang.String