Compiling function below produces a weird error,
def sqrtOption(n:Int):(Option[Double])=
var ret:Option[Double]=Some(0.0)
if n>=0 then
ret=Some(Math.sqrt(n))
else
ret=None
end if
ret
end sqrtOption
Error:
../compile
-- [E007] Type Mismatch Error: Test.scala:21:10 ----------------------------------------------------------------
21 | ret=None
| ^^^^
| Found: |None.type
| Required: |Option[Double]
Explanation
===========
Tree: 21|None
I tried to show that
|None.type
conforms to
|Option[Double]
but the comparison trace ended with `false`: