Skip to content

Commit 7d316ae

Browse files
Merge pull request #860 from scala/tweak-859
Add tut:fail and tut:nofail to Jekyll plugin tweaks #859
2 parents 3be9890 + f5bb158 commit 7d316ae

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Scala Documentation #
2+
23
[![Build Status](https://platform-ci.scala-lang.org/api/badges/scala/docs.scala-lang/status.svg)](https://platform-ci.scala-lang.org/scala/docs.scala-lang)
34

45
This repository contains the source for the Scala documentation website, as well as the source for "Scala Improvement Process" (SIP) documents.

_plugins/tut_replace.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ def output_ext(ext)
1212
end
1313

1414
def convert(content)
15-
content.gsub("```tut\n", "```scala\n")
15+
content = content.gsub("```tut:fail\n", "```scala\n")
16+
content = content.gsub("```tut:nofail\n", "```scala\n")
17+
content.gsub("```tut\n", "```scala\n")
1618
end
1719
end
1820
end

_tour/lower-type-bounds.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ While [upper type bounds](upper-type-bounds.html) limit a type to a subtype of a
1818

1919
Here is an example where this is useful:
2020

21-
```tut
21+
```tut:fail
2222
trait Node[+B] {
2323
def prepend(elem: B): Unit
2424
}
@@ -33,6 +33,7 @@ case class Nil[+B]() extends Node[B] {
3333
def prepend(elem: B) = ListNode[B](elem, this)
3434
}
3535
```
36+
3637
This program implements a singly-linked list. `Nil` represents an empty element (i.e. an empty list). `class ListNode` is a node which contains an element of type `B` (`head`) and a reference to the rest of the list (`tail`). The `class Node` and its subtypes are covariant because we have `+B`.
3738

3839
However, this program does _not_ compile because the parameter `elem` in `prepend` is of type `B`, which we declared *co*variant. This doesn't work because functions are *contra*variant in their parameter types and *co*variant in their result types.

0 commit comments

Comments
 (0)