Skip to content

Instantly share code, notes, and snippets.

@markhibberd
Created February 4, 2013 09:51
Pattern matching on `Nothing`
Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val x: Option[Nothing] = None
x: Option[Nothing] = None
scala> x match {
| case Some(a) => a
| case None => None
| }
res0: None.type = None
scala> x match {
| case None => None
| }
<console>:9: warning: match may not be exhaustive.
It would fail on the following input: Some(_)
x match {
^
res1: None.type = None
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val x: Option[Nothing] = None
x: Option[Nothing] = None
scala> x match {
| case Some(a) => a
| case None => None
| }
res0: None.type = None
scala> x match {
| case None => None
| }
res1: None.type = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment