Skip to content

Commit f967ea7

Browse files
committed
adjust formatting
1 parent 1aea632 commit f967ea7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

_overviews/scala3-book/taste-contextual-abstractions.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,22 @@ It is convenient to omit it because we know `String`s are generally compared usi
4545

4646
However, it is also possible to pass it explicitly:
4747

48-
{% tabs contextual_2 %}
49-
{% tab 'Scala 3 Only' for=contextual_2 %}
48+
{% tabs contextual_2 class=tabs-scala-version %}
49+
{% tab 'Scala 2' for=contextual_2 %}
50+
51+
```scala
52+
addresses.sortBy(address => (address.city, address.street))(Ordering.Tuple2(Ordering.String, Ordering.String))
53+
```
54+
55+
{% endtab %}
56+
{% tab 'Scala 3' for=contextual_2 %}
5057

5158
```scala
5259
addresses.sortBy(address => (address.city, address.street))(using Ordering.Tuple2(Ordering.String, Ordering.String))
5360
```
5461

62+
in Scala 3 `using` in an argument list to `sortBy` signals passing the context parameter explicitly, avoiding ambiguity.
63+
5564
{% endtab %}
5665
{% endtabs %}
5766

0 commit comments

Comments
 (0)