Skip to content

Instantly share code, notes, and snippets.

@emmettna
Created January 20, 2020 04:24
Show Gist options
  • Save emmettna/40de8666d3ed8f26bdd5a74a29ad7c1a to your computer and use it in GitHub Desktop.
Save emmettna/40de8666d3ed8f26bdd5a74a29ad7c1a to your computer and use it in GitHub Desktop.
final case class DummyCaseClass(value: Int)
val dummyCaseClassOpt = Option(DummyCaseClass(1))
dummyCaseClassOpt match {
case Some(DummyCaseClass(v)) => v.toString
case Some(_) => ???
case None => ???
}
// equivalent
dummyCaseClassOpt match {
case v: Some[DummyCaseClass] => v.toString
case v: Some[_] => ???
case None => ???
}
// similar. But why would you ?
if (dummyCaseClassOpt.isInstanceOf[Some[IntegerParser]]) "1" else ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment