Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
Created October 29, 2015 04:20
Show Gist options
  • Save puffnfresh/5852cd41c30604342fa2 to your computer and use it in GitHub Desktop.
Save puffnfresh/5852cd41c30604342fa2 to your computer and use it in GitHub Desktop.
null.asInstanceOf[Int].asInstanceOf[String]
scala> null.asInstanceOf[Int]
res0: Int = 0
scala> 0.asInstanceOf[String]
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
... 33 elided
scala> null.asInstanceOf[Int].asInstanceOf[String]
res2: String = null
@puffnfresh
Copy link
Author

2015-10-29 15:21 <dibblego> ! null.asInstanceOf[Int].asInstanceOf[Integer] ==
                            null.asInstanceOf[Int]
2015-10-29 15:21 <multibot_>  Boolean = true
2015-10-29 15:21 <puffnfresh> wait wat?
2015-10-29 15:22 <dibblego> omfg fuck it I don't know

@xuwei-k
Copy link

xuwei-k commented Oct 29, 2015

http://stackoverflow.com/a/10750800

depends on the context in which it is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment