Skip to content

Commit af24df3

Browse files
Add section on new pattern-bound given instances
1 parent f56d1f5 commit af24df3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/blog/_posts/2020-11-09-scala3-m1.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ As of Scala 3.1.0, the `@` syntax will be deprecated and the codebases should sw
4949

5050
This change was implemented by PR [#9837](https://github.com/lampepfl/dotty/pull/9837).
5151

52+
# Pattern-Bound Given Instances
53+
The syntax for `given` instances in patterns has also changed. In the `for`-comprehensions, the correct way of using `given`s is as follows:
54+
55+
```scala
56+
for given Context <- applicationContexts do
57+
```
58+
59+
And in `match` clauses, you can use them as follows:
60+
61+
```scala
62+
pair match
63+
case (ctx as given Context, y) => ...
64+
```
65+
66+
For more information, see [documentation](https://dotty.epfl.ch/docs/reference/contextual/givens.html#pattern-bound-given-instances), and for discussion, see PR [#10091](https://github.com/lampepfl/dotty/pull/10091).
67+
5268
# Change wildcard given selectors
5369
This is another syntactic change which aims to simplify the code. Instead of:
5470

0 commit comments

Comments
 (0)