Yup :) And false for `Boolean`, \u0000 for char and null for all references types Gotta love trait initialization!
-
-
Right. Primitive null.
1 reply 0 retweets 0 likes -
‘Primitive null’ sounds very much like an insult to null, which I approve.
1 reply 0 retweets 10 likes -
But, did you see that it's finding the implicit in B, not the one in A? You can delete the trait, extends and override and you get the same answer.
1 reply 0 retweets 1 like -
Ah, yes of course. I've minimized the example from a real case that happened at work, but it's not as minimal as I thought!
1 reply 0 retweets 0 likes -
I mean, val a: Int = a is even more minimal!
2 replies 0 retweets 2 likes -
Replying to @propensive @gabro27 and
Incidentally, Scala forces you to explicitly cast a literal null to a (potentially) primitive value since around Scala 2.6. If T is not known to be a subtype of AnyRef, and you give it a Null-typed thing (viz, null), you have to explicitly cast it to T.
2 replies 0 retweets 0 likes -
Ah yes, I was aware of that. Does the cast resolve to a primitive value at runtime, or does it just explode? Meaning: val a: Int = null.asInstanceOf[Int]
1 reply 0 retweets 1 like -
Nope, doesn't explode.
1 reply 0 retweets 0 likes -
Sorry for using you as a REPL, but is the value 0 or null if you print it?
2 replies 0 retweets 0 likes
You never get a null from anything that's been forced into a primitive.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.