Skip to content

Commit

Permalink
Fix mdoc rendering of exercise solutions
Browse files Browse the repository at this point in the history
Seems to be an mdoc bug, but it was easy to work around.

Turned off mdoc for some code snippets, but they are very simple and
this is unlikely to cause issues in the future.

Closes #83
  • Loading branch information
noelwelsh committed May 24, 2024
1 parent 4afc887 commit 0dcf2ce
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions book/src/pages/expressions/05-exercises.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ Then try to check your guesses using the worksheet. If you guessed wrong, try to
@:@

@:solution
```scala mdoc
```scala
1 + 2
```

Easy example as we've seen this one before. This expression has type `Int` and evaluates to `3`.


```scala mdoc:fail
```scala
1 ? 2
// error:
// value ? is not a member of Int
```

This is not a valid expression and does not compile. As such it doesn't have a type.
Expand All @@ -91,7 +93,7 @@ This expression has type `Int` and evaluates to `2`.

This expression has type `Int` and evaluates to `0`. People coming from dynamically typed languages will sometimes guess that this evaluates to `0.5` and hence the type would be a floating point number. This would require we pass information back from the run-time to compile-time, which is not possible.

```scala mdoc:fail
```scala mdoc:crash
1 / 0
```

Expand Down

1 comment on commit 0dcf2ce

@benoitpas
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one, well done !

Please sign in to comment.