Skip to content

Add tut:fail and tut:nofail to Jekyll plugin tweaks #859 #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 11, 2017
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Scala Documentation #

[![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)

This repository contains the source for the Scala documentation website, as well as the source for "Scala Improvement Process" (SIP) documents.
Expand Down
4 changes: 3 additions & 1 deletion _plugins/tut_replace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def output_ext(ext)
end

def convert(content)
content.gsub("```tut\n", "```scala\n")
content = content.gsub("```tut:fail\n", "```scala\n")
content = content.gsub("```tut:nofail\n", "```scala\n")
content.gsub("```tut\n", "```scala\n")
end
end
end
3 changes: 2 additions & 1 deletion _tour/lower-type-bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ While [upper type bounds](upper-type-bounds.html) limit a type to a subtype of a

Here is an example where this is useful:

```tut
```tut:fail
trait Node[+B] {
def prepend(elem: B): Unit
}
Expand All @@ -33,6 +33,7 @@ case class Nil[+B]() extends Node[B] {
def prepend(elem: B) = ListNode[B](elem, this)
}
```

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`.

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.
Expand Down