Scala\'s Option class has an orNull
method, whose signature is shown below.
orNull [A1 >: A](implicit ev : <:<[Null, A1]) : A1
Re : 'how' is this used - one place we are finding this useful is when dealing with java api mappings where null
is commonplace, e.g. on jdbc prepared statements to nullable sql columns. The Option
al internal model fields can be mapped:
stmt.setDate("field", myModel.myDateField.orNull)
Instead of the more verbose:
stmt.setDate("field", myModel.myDateField.getOrElse(null))