Skip to content

Commit d7ee4eb

Browse files
committed
Fix docs by replacing @infix with infix
1 parent 4e93ea7 commit d7ee4eb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/docs/reference/contextual/extension-methods.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extension (x: String)
4040
extension (x: Elem)
4141
def +: (xs: Seq[Elem]): Seq[Elem] = ...
4242
extension (x: Number)
43-
@infix def min (y: Number): Number = ...
43+
infix def min (y: Number): Number = ...
4444

4545
"ab" < "c"
4646
1 +: List(2, 3)
@@ -52,7 +52,7 @@ The three definitions above translate to
5252
```scala
5353
<extension> def < (x: String)(y: String): Boolean = ...
5454
<extension> def +: (xs: Seq[Elem])(x: Elem): Seq[Elem] = ...
55-
@infix <extension> def min(x: Number)(y: Number): Number = ...
55+
infix <extension> def min(x: Number)(y: Number): Number = ...
5656
```
5757

5858
Note the swap of the two parameters `x` and `xs` when translating
@@ -113,6 +113,7 @@ extension (ss: Seq[String]):
113113
```
114114

115115
The same can be written with braces as follows (note that indented regions can still be used inside braces):
116+
116117
```scala
117118
extension (ss: Seq[String]) {
118119

@@ -239,11 +240,13 @@ The following two rewritings are tried in order:
239240
from `T` to a type containing `m`. If there is more than one way of rewriting, an ambiguity error results.
240241

241242
An extension method can also be referenced using a simple identifier without a preceding expression. If an identifier `g` appears in the body of an extension method `f` and refers to an extension method `g` that is defined in the same collective extension
243+
242244
```scala
243245
extension (x: T)
244246
def f ... = ... g ...
245247
def g ...
246248
```
249+
247250
the identifier is rewritten to `x.g`. This is also the case if `f` and `g` are the same method. Example:
248251

249252
```scala
@@ -261,7 +264,6 @@ def position(s: String)(ch: Char, n: Int): Int =
261264
else n
262265
```
263266

264-
265267
### Syntax
266268

267269
Here are the syntax changes for extension methods and collective extensions relative

0 commit comments

Comments
 (0)