Skip to content

Commit c87d501

Browse files
committed
Fix opaque type examples
1 parent 10526a7 commit c87d501

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/docs/reference/other-new-features/opaques.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object Logarithms {
2323
delegate LogarithmOps {
2424
def (x: Logarithm) toDouble: Double = math.exp(x)
2525
def (x: Logarithm) + (y: Logarithm): Logarithm = Logarithm(math.exp(x) + math.exp(y))
26-
def (x: Logarithm) * (y: Logarithm): Logarithm = Logarithm(x + y)
26+
def (x: Logarithm) * (y: Logarithm): Logarithm = x + y
2727
}
2828
}
2929
```
@@ -69,15 +69,15 @@ object Access {
6969
opaque type PermissionChoice = Int
7070
opaque type Permission <: Permissions & PermissionChoice = Int
7171

72-
def (x: Permissions) & (y: Permissions): Permissions = x & y
72+
def (x: Permissions) & (y: Permissions): Permissions = x | y
7373
def (x: PermissionChoice) | (y: PermissionChoice): PermissionChoice = x | y
7474
def (x: Permissions) is (y: Permissions) = (x & y) == y
7575
def (x: Permissions) isOneOf (y: PermissionChoice) = (x & y) != 0
7676

7777
val NoPermission: Permission = 0
7878
val ReadOnly: Permission = 1
7979
val WriteOnly: Permission = 2
80-
val ReadWrite: Permissions = ReadOnly & WriteOnly
80+
val ReadWrite: Permissions = ReadOnly | WriteOnly
8181
val ReadOrWrite: PermissionChoice = ReadOnly | WriteOnly
8282
}
8383
```

0 commit comments

Comments
 (0)