Skip to content

Commit 082841d

Browse files
authored
doc(operators): typo and add import to examples
1 parent 3e68e93 commit 082841d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/docs/reference/changed-features/operators.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Furthermore, a syntax change allows infix operators to be written on the left in
1010

1111
An `@alpha` annotation on a method definition defines an alternate name for the implementation of that method: Example:
1212
```scala
13+
import scala.annotation.alpha
14+
1315
object VecOps {
1416
@alpha("append") def (xs: Vec[T]) ++= [T] (ys: Vec[T]): Vec[T] = ...
1517
}
@@ -47,7 +49,7 @@ The `@alpha` annotation serves a dual purpose:
4749
5. Definitions with names in backticks that are not legal host platform names
4850
should have an `@alpha` annotation. Lack of such an annotation will raise a deprecation warning.
4951

50-
6. @alpha annotations must agree: If two definitions are members of an object or class with the same name and matching types, then either none of them has an `@alpha` annotation, or both have `@alpha` annotations with the same name.
52+
6. `@alpha` annotations must agree: If two definitions are members of an object or class with the same name and matching types, then either none of them has an `@alpha` annotation, or both have `@alpha` annotations with the same name.
5153

5254
7. There must be a one-to-one relationship between external and internal names:
5355
If two definitions are members of an object or class with matching types and both have `@alpha` annotations with the same external name, then their internal method names must also be the same.
@@ -56,6 +58,8 @@ The `@alpha` annotation serves a dual purpose:
5658

5759
An `@infix` annotation on a method definition allows using the method as an infix operation. Example:
5860
```scala
61+
import scala.annotation.alpha
62+
5963
trait MultiSet[T] {
6064

6165
@infix
@@ -70,13 +74,15 @@ trait MultiSet[T] {
7074
val s1, s2: MultiSet[Int]
7175

7276
s1 union s2 // OK
77+
s1 `union` s2 // also OK but unusual
7378
s1.union(s2) // also OK
7479

7580
s1.difference(s2) // OK
7681
s1 `difference` s2 // OK
7782
s1 difference s2 // gives a deprecation warning
7883

7984
s1 * s2 // OK
85+
s1 `*` s2 // also OK, but unusual
8086
s1.*(s2) // also OK, but unusual
8187
```
8288
Infix operations involving alphanumeric operators are deprecated, unless
@@ -118,7 +124,7 @@ The purpose of the `@infix` annotation is to achieve consistency across a code b
118124
@infix def (x: A) op (y1: B, y2: B): R // error: two parameters
119125
```
120126

121-
4. @infix annotations can also be given to type, trait or class definitions that have exactly two type parameters. An infix type like
127+
4. `@infix` annotations can also be given to type, trait or class definitions that have exactly two type parameters. An infix type like
122128

123129
```scala
124130
@infix type op[X, Y]

0 commit comments

Comments
 (0)