Skip to content

Fixes for tour/lower-type-bounds #989

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 1 commit into from
Jan 14, 2018
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
16 changes: 8 additions & 8 deletions _ba/tour/lower-type-bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ Kroz sljedeći primjer vidjećemo zašto je ovo korisno:

```tut:fail
trait Node[+B] {
def prepend(elem: B): Unit
def prepend(elem: B): Node[B]
}

case class ListNode[+B](h: B, t: Node[B]) extends Node[B] {
def prepend(elem: B) = ListNode[B](elem, this)
def prepend(elem: B): ListNode[B] = ListNode(elem, this)
Copy link
Member

Choose a reason for hiding this comment

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

The automatic insertion of Unit by the compiler sometimes bothers me.

def head: B = h
def tail = t
def tail: Node[B] = t
}

case class Nil[+B]() extends Node[B] {
def prepend(elem: B) = ListNode[B](elem, this)
def prepend(elem: B): ListNode[B] = ListNode(elem, this)
}
```

Expand All @@ -48,17 +48,17 @@ Ovo radimo uvođenjem novog tipskog parametra `U` koji ima `B` kao svoju donju g

```tut
trait Node[+B] {
def prepend[U >: B](elem: U)
def prepend[U >: B](elem: U): Node[U]
}

case class ListNode[+B](h: B, t: Node[B]) extends Node[B] {
def prepend[U >: B](elem: U) = ListNode[U](elem, this)
def prepend[U >: B](elem: U): ListNode[U] = ListNode(elem, this)
def head: B = h
def tail = t
def tail: Node[B] = t
}

case class Nil[+B]() extends Node[B] {
def prepend[U >: B](elem: U) = ListNode[U](elem, this)
def prepend[U >: B](elem: U): ListNode[U] = ListNode(elem, this)
}
```

Expand Down
14 changes: 7 additions & 7 deletions _tour/lower-type-bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ Here is an example where this is useful:

```tut:fail
trait Node[+B] {
def prepend(elem: B): Unit
def prepend(elem: B): Node[B]
}

case class ListNode[+B](h: B, t: Node[B]) extends Node[B] {
def prepend(elem: B) = ListNode[B](elem, this)
def prepend(elem: B): ListNode[B] = ListNode(elem, this)
def head: B = h
def tail = t
def tail: Node[B] = t
}

case class Nil[+B]() extends Node[B] {
def prepend(elem: B) = ListNode[B](elem, this)
def prepend(elem: B): ListNode[B] = ListNode(elem, this)
}
```

Expand All @@ -46,13 +46,13 @@ trait Node[+B] {
}

case class ListNode[+B](h: B, t: Node[B]) extends Node[B] {
def prepend[U >: B](elem: U) = ListNode[U](elem, this)
def prepend[U >: B](elem: U): ListNode[U] = ListNode(elem, this)
def head: B = h
def tail = t
def tail: Node[B] = t
}

case class Nil[+B]() extends Node[B] {
def prepend[U >: B](elem: U) = ListNode[U](elem, this)
def prepend[U >: B](elem: U): ListNode[U] = ListNode(elem, this)
}
```

Expand Down