14 June 2013

Scala Notes 11: Enumerations

Information:
Scala notes is series of my "side comments" .
They can be useful for me during revision of  Scala in future use.
They contains bunch of information about interesting bits.
They helps me to understand difference between Java and Scala. 
 They contains an explanation of things that I didn't come across yet or I  attempt to explain things in easy and friendly way of topics and theories that I didn't understand.

Enumerations:

Wikipedia said: "An enumeration of a collection of items is a complete, ordered listing of all of the items in that collection. "

Javadoc said:  "An enum type is a special data type that enables for a variable to be a set of predefined constants "
  • Examples:  days,directions and etc.
  • As they are  constants, the names of an enum type's fields are in uppercase letters.
  • In the Java programming language, you define an enum type by using the enum keyword
So ... How it looks in Scala ?
Scala API defines Enumeration as "a finite set of values specific to the enumeration"


Scala implements Enumeration as a class in its standard library not as a built-in part (like Java).   Scala’s Enumeration class supports the usual set of methods to work with collections.


Resources:
http://www.scala-lang.org/api/current/index.html#scala.Enumeration
http://ofps.oreilly.com/titles/9780596155957/RoundingOutTheEssentials.html
http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html
http://en.wikipedia.org/wiki/Enumerated_type
http://en.wikipedia.org/wiki/Enumeration





No comments:

Post a Comment