Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions _overviews/scala3-book/packaging-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ The syntax shown above applies to the entire source file: all the definitions in
at the beginning of the file.

Alternatively, it is possible to write package clauses that apply only to the definitions
they contain:
they contain:

{% tabs packaging-imports-1 class=tabs-scala-version %}
{% tab 'Scala 2' %}```scala
{% tabs packaging-imports-0 class=tabs-scala-version %}
{% tab 'Scala 2' %}
```scala
package users {

package administrators { // the full name of this package is users.administrators
Expand All @@ -63,7 +64,7 @@ package users {
```

{% endtab %}
{% tab 'Scala 3' for=packaging-imports-1 %}
{% tab 'Scala 3' %}

```scala
package users:
Expand Down Expand Up @@ -462,7 +463,7 @@ The basic form is shown in this example:
```scala
object A:
class TC
given tc as TC
given tc: TC
def f(using TC) = ???

object B:
Expand Down Expand Up @@ -527,10 +528,10 @@ For example, when you have this `object`:
{% tab 'Scala 3 only' %}
```scala
object Instances:
given intOrd as Ordering[Int]
given listOrd[T: Ordering] as Ordering[List[T]]
given ec as ExecutionContext = ...
given im as Monoid[Int]
given intOrd: Ordering[Int]
given listOrd[T: Ordering]: Ordering[List[T]]
given ec: ExecutionContext = ...
given im: Monoid[Int]
```
{% endtab %}
{% endtabs %}
Expand Down Expand Up @@ -570,14 +571,14 @@ object MonthConversions:
def convert(a: A): String

given intMonthConverter: MonthConverter[Int] with
def convert(i: Int): String =
def convert(i: Int): String =
i match
case 1 => "January"
case 2 => "February"
// more cases here ...

given stringMonthConverter: MonthConverter[String] with
def convert(s: String): String =
def convert(s: String): String =
s match
case "jan" => "January"
case "feb" => "February"
Expand Down
Loading