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.
Null
is an unfortunate legacy from Java and should never be used in original Scala code. You are just begging for run-time errors.