I have a Scala method that takes 2 parameters:
def test(x:Long,y:Int){}
On some occasion I need to pass null instead of long ... something like that:
test(null,x)
The result:
scala> test(null,2) :7: error: type mismatch; found : Null(null) required: Long test(null,2)
Why do I need to pass null? Actually ,for some reason,I can't pass any default values. Thus, I need such a null.
*Note:*I know that the solution would be making it Option. However let's say I have no control over this method signature,can I do any work around?
Any ideas!
Thanks.
Long
in fact maps to the JVM primitive typelong
. So, a ScalaLong
cannot benull
, because primitive types cannot benull
. (Don't confusescala.Long
withjava.lang.Long
!). – Unrighteous