I'm new to Scala. I have a Scala function, and one of its arguments uses "Option":
def generateTimeSnippet(startOfSentence: Double, endOfSentence: Option[Double]): (Double, Option[Double]) = {
...
}
When I call this function, I give literal values to the arguments:
val snippets = generateTimeSnippet(startOfSentence = 10d, endOfSentence = 20.5)
But this results in a type mismatch error: "type mismatch; found : Double(10.0) required: Option[Double]"
I find this very odd. Why is this happening? Am I not supposed to be allowed to use Doubles for an argument that is defined as Option[Double]?
Option
is not a special language feature. It is an ordinary type. – Chris Martin