Skip to content

Instantly share code, notes, and snippets.

@zakki
Created October 17, 2013 04:51
Show Gist options
  • Select an option

  • Save zakki/7019336 to your computer and use it in GitHub Desktop.

Select an option

Save zakki/7019336 to your computer and use it in GitHub Desktop.
enum.scala:22: warning: match may not be exhaustive. It would fail on the following input: Some((x: Status.Status forSome x not in (Error, Processed, Rendering, Waiting)))
object Status extends Enumeration {
type Status = Value
val Waiting = Value("waiting")
val Rendering = Value("rendering")
val Processed = Value("processed")
val Error = Value("error")
}
object Main extends App {
import Status._
def foo(s: Status) = {
s match {
case Waiting =>
println("A")
case Rendering =>
println("B")
case Processed | Error =>
println("C")
}
}
def bar(s: Option[Status]) = {
s match {
case Some(Waiting) =>
println("A")
case Some(Rendering) =>
println("B")
case Some(Processed) | Some(Error) | None =>
println("C")
}
}
foo(Waiting)
foo(Error)
bar(Some(Rendering))
bar(Some(Processed))
bar(None)
}
@xuwei-k
Copy link
Copy Markdown

xuwei-k commented Oct 17, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment