Created
December 23, 2011 07:57
-
-
Save lshoo/1513526 to your computer and use it in GitHub Desktop.
programming in scala chapter 20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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