Created
February 4, 2013 09:51
Pattern matching on `Nothing`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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