Skip to content

Instantly share code, notes, and snippets.

@asflierl
Created August 4, 2016 14:05
Show Gist options
  • Save asflierl/407058ecea465765f5015245ed11d229 to your computer and use it in GitHub Desktop.
Save asflierl/407058ecea465765f5015245ed11d229 to your computer and use it in GitHub Desktop.
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