I am creating my Scala bean which is a configuration to be loaded from a YML config. I want a long property to be null if not specified, but I'm facing below issue. Any idea why?
startOffset: Integer = null
scala> var endOffset: Long = null
<console>:11: error: an expression of type Null is ineligible for implicit conversion
var endOffset: Long = null
^`
PS: Yes I can use Option[Long]
but wanted clarity and is there anything wrong with this approach.
Scala Long
is literal data type like long
in Java. Same is true for Int
.
But Integer
is a Wrapper class i.e java.lang.Integer
If you want nullable Long value, you can use java.lang.Long
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With