Skip to content

Commit e23b8da

Browse files
Small note to describe Nil
This is the first time the user comes across Nil in the tutorial, so a small explanation of what it is.
1 parent 6f27acd commit e23b8da

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

_tour/generic-classes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class Stack[A] {
3131
```
3232
This implementation of a `Stack` class takes any type `A` as a parameter. This means the underlying list, `var elements: List[A] = Nil`, can only store elements of type `A`. The procedure `def push` only accepts objects of type `A` (note: `elements = x :: elements` reassigns `elements` to a new list created by prepending `x` to the current `elements`).
3333

34+
`Nil` here is a special case of `List` and is not to be confused with `Null`. It is a `List` of zero length.
35+
3436
## Usage
3537

3638
To use a generic class, put the type in the square brackets in place of `A`.

0 commit comments

Comments
 (0)