title: Casting null to Int and Double in Scala
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10749010/if-an-int-cant-be-null-what-does-null-asinstanceofint-mean">If an Int can&#39;t be null, what does null.asInstanceOf[Int] mean?</a>  </p>
  </blockquote>
  
  
  
  <p>I tried the following in REPL:</p>
  
  <pre>scala> null.asInstanceOf[Int]
  res12: Int = 0
  
  scala> null.asInstanceOf[Float]
  res13: Float = 0.0
  
  scala> null.asInstanceOf[Double]
  res14: Double = 0.0
  </pre>
  
  <p>It would expect a runtime exception (<code>NPE</code> or <code>ClassCastException</code>) in that case.<br>
  Could anybody explain <em>why</em> Scala casts <code>null</code> to zero?</p>