Created
August 4, 2016 14:05
-
-
Save asflierl/407058ecea465765f5015245ed11d229 to your computer and use it in GitHub Desktop.
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 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_80). | |
Type in expressions for evaluation. Or try :help. | |
scala> object Meep { val meep = "meep" } | |
defined object Meep | |
scala> class Moop { def x = null.asInstanceOf[Meep.type].meep } | |
defined class Moop | |
scala> new Moop().x | |
java.lang.NullPointerException | |
at Moop.x(<console>:12) | |
... 32 elided | |
scala> object Meep2 { final val meep = "meep" } | |
defined object Meep2 | |
scala> class Moop2 { def x = null.asInstanceOf[Meep2.type].meep } | |
defined class Moop2 | |
scala> new Moop2().x | |
res0: String = meep | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment