From e23b8da7b95c5ad7b2044a9a4259784f7936cdb9 Mon Sep 17 00:00:00 2001 From: manishpatelUK Date: Thu, 1 Aug 2019 08:34:40 +0100 Subject: [PATCH 1/3] 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. --- _tour/generic-classes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_tour/generic-classes.md b/_tour/generic-classes.md index 2433cd6b45..a93045de1e 100644 --- a/_tour/generic-classes.md +++ b/_tour/generic-classes.md @@ -31,6 +31,8 @@ class Stack[A] { ``` 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`). +`Nil` here is a special case of `List` and is not to be confused with `Null`. It is a `List` of zero length. + ## Usage To use a generic class, put the type in the square brackets in place of `A`. From 193392e0128a1f0aac2f543f7b86dc31bfb55395 Mon Sep 17 00:00:00 2001 From: manishpatelUK Date: Fri, 2 Aug 2019 10:34:30 +0100 Subject: [PATCH 2/3] Update generic-classes.md --- _tour/generic-classes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tour/generic-classes.md b/_tour/generic-classes.md index a93045de1e..6407fc7b66 100644 --- a/_tour/generic-classes.md +++ b/_tour/generic-classes.md @@ -31,7 +31,7 @@ class Stack[A] { ``` 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`). -`Nil` here is a special case of `List` and is not to be confused with `Null`. It is a `List` of zero length. +`Nil` here is a special case of `List` and is not to be confused with `Null`. It is simply an empty list. ## Usage From a56f7af6c04a00282707c93d6132e23d7303f64c Mon Sep 17 00:00:00 2001 From: manishpatelUK Date: Fri, 2 Aug 2019 10:45:13 +0100 Subject: [PATCH 3/3] Update generic-classes.md comment response --- _tour/generic-classes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tour/generic-classes.md b/_tour/generic-classes.md index 6407fc7b66..9088cc95d8 100644 --- a/_tour/generic-classes.md +++ b/_tour/generic-classes.md @@ -31,7 +31,7 @@ class Stack[A] { ``` 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`). -`Nil` here is a special case of `List` and is not to be confused with `Null`. It is simply an empty list. +`Nil` here is an empty `List` and is not to be confused with `Null`. ## Usage