Skip to content

Commit

Permalink
Add section on new pattern-bound given instances
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoliykmetyuk committed Nov 9, 2020
1 parent f56d1f5 commit af24df3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/blog/_posts/2020-11-09-scala3-m1.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ As of Scala 3.1.0, the `@` syntax will be deprecated and the codebases should sw

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

# Pattern-Bound Given Instances
The syntax for `given` instances in patterns has also changed. In the `for`-comprehensions, the correct way of using `given`s is as follows:

```scala
for given Context <- applicationContexts do
```

And in `match` clauses, you can use them as follows:

```scala
pair match
case (ctx as given Context, y) => ...
```

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).

# Change wildcard given selectors
This is another syntactic change which aims to simplify the code. Instead of:

Expand Down

0 comments on commit af24df3

Please sign in to comment.