Skip to content

Commit

Permalink
fix packaging and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha authored and julienrf committed Jul 17, 2023
1 parent 2caa174 commit fed33f2
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 73 deletions.
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

0 comments on commit fed33f2

Please sign in to comment.