In Scala there are 2 representations of double-precision numbers, one is an AnyVal
, the other AnyRef
. On the JVM they are mapped to the primitive double
and the class java.lang.Double
respectively.
Now what happens on platforms other than the JVM? I can use Scala.Double
for the primitive, but how do I specify that I want a reference to the boxed Double without specifying java.lang.Double
?
[Context - left to make sense of Thomasz' answer, but not the fundamental issue.
I have a Double that I want to inject with Spring into a Wicket component:
class MyPanel(id: String) extends Panel(id) {
@SpringBean(name="rxAlarmLimitDb") var alarmLimitDb: Double = _
If I specify the type as scala.Double
as above, the injector fails, as it can only inject Objects.
If I specify java.lang.Double
as the type of the field, all is well
class MyPanel(id: String) extends Panel(id) {
@SpringBean(name="rxAlarmLimitDb") var alarmLimitDb: java.lang.Double = _
But I'm trying to reduce my dependance on falling back on the Java API, so how do I represent the boxed Double
without it?
]
java.lang.Double
-- just like Scala uses Java classes for a lot of other things (AnyRef = java.lang.Object, String = java.lang.String). I don't know for sure, though. – Moreno