Skip to content

Instantly share code, notes, and snippets.

@lshoo
Created December 23, 2011 07:57
Show Gist options
  • Save lshoo/1513526 to your computer and use it in GitHub Desktop.
Save lshoo/1513526 to your computer and use it in GitHub Desktop.
programming in scala chapter 20
package ch20
object Color extends Enumeration {
val RED = Value("abcdefg")
val GREEN, BLUE = Value
val yellow = Value
val Orange = Value
//override def toString = Value.toString.toLowerCase
}
object Direction extends Enumeration {
val North, East, South, West = Value
}
object EnuerationDemo {
def main(args: Array[String]) {
println(Color.BLUE.toString.toLowerCase)
println(Color.GREEN)
println(Color.RED)
println(Color.yellow)
println(Color.Orange)
for (d <- Direction.values) print(d + " ")
println(Direction.East.id)
println(Direction(2))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment