Skip to content

Commit e5148f8

Browse files
committed
docs: add import notice for extension methods
1 parent 2786af9 commit e5148f8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

_overviews/scala3-book/ca-extension-methods.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ Then in your code you use `circumference` just as though it was originally defin
5050
aCircle.circumference
5151
```
5252

53+
### Import extension method
54+
55+
Imagine, that `circumference` is defined in package `lib`, you can import it by
56+
57+
```scala
58+
import lib.circumference
59+
60+
aCircle.circumference
61+
```
62+
63+
the compiler also support you if the import is missing by
64+
65+
```text
66+
value circumference is not a member of Circle, but could be made available as an extension method.
67+
68+
The following import might fix the problem:
69+
70+
import lib.circumference
71+
```
5372

5473
## Discussion
5574

0 commit comments

Comments
 (0)