Skip to content

Commit a2f2639

Browse files
authored
Update matchable.md
The type has to of the method has to be specified or else the return types will just be a Double in both cases and the tests will pass. Strict Equality has to be set for the compiler to fail.
1 parent 8bbce58 commit a2f2639

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

_scala3-reference/other-new-features/matchable.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ For instance, consider the definitions
122122

123123
```scala
124124
opaque type Meter = Double
125-
def Meter(x: Double) = x
125+
def Meter(x: Double): Meter = x
126126

127127
opaque type Second = Double
128-
def Second(x: Double) = x
128+
def Second(x: Double): Second = x
129129
```
130130

131131
Here, universal `equals` will return true for
@@ -137,6 +137,7 @@ Here, universal `equals` will return true for
137137
even though this is clearly false mathematically. With [multiversal equality](../contextual/multiversal-equality.html) one can mitigate that problem somewhat by turning
138138

139139
```scala
140+
import scala.language.strictEquality
140141
Meter(10) == Second(10)
141142
```
142143

0 commit comments

Comments
 (0)