Skip to content

Instantly share code, notes, and snippets.

@gkazior
Last active March 18, 2016 11:34
Show Gist options
  • Save gkazior/642ef133004be6f7abd8 to your computer and use it in GitHub Desktop.
Save gkazior/642ef133004be6f7abd8 to your computer and use it in GitHub Desktop.
Scala enum - pattern when I do not use java enum
/** Ensure statuses */
object EnsureStatus {
sealed trait Type
case object Created extends Type // cannot match so need to create
case object Modified extends Type // matched and modified
case object NotModified extends Type // matched and not modified
val statuses = (Created, Modified, NotModified)
}
val status: EnsureStatus.Type = EnsureStatus.Created
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment