Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created March 31, 2015 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/6be38d0b9a11cc9c03f1 to your computer and use it in GitHub Desktop.
Save shigemk2/6be38d0b9a11cc9c03f1 to your computer and use it in GitHub Desktop.
object Color extends Enumeration {
val Blue, Red, Green, White = Value
}
object Main {
import Color._
def main(args: Array[String]): Unit = {
// id
println(Blue.id)
println(Red.id)
println(Green.id)
println(White.id)
// apply
println(Color(0))
println(Color(1))
println(Color(2))
println(Color(3))
// maxId
println(Color.maxId)
// values
println(Color.values)
// withName
println(Color.withName("Red"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment