aboutsummaryrefslogtreecommitdiff
path: root/lessons/src/lesson035_nil
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2023-12-20 20:46:44 +0000
committerLouis Pilfold <louis@lpil.uk>2023-12-20 20:46:44 +0000
commit2a6ae1fa5408247c95bf4a7d59e5038342a2a125 (patch)
tree3d0812a584c81762a91cbb8c32b64e7b3996f621 /lessons/src/lesson035_nil
parentee4820f0dfcd03ce915fbd08564eec0abad428db (diff)
downloadtour-2a6ae1fa5408247c95bf4a7d59e5038342a2a125.tar.gz
tour-2a6ae1fa5408247c95bf4a7d59e5038342a2a125.zip
Nil and bit arrays
Diffstat (limited to 'lessons/src/lesson035_nil')
-rw-r--r--lessons/src/lesson035_nil/code.gleam11
-rw-r--r--lessons/src/lesson035_nil/text.html15
2 files changed, 26 insertions, 0 deletions
diff --git a/lessons/src/lesson035_nil/code.gleam b/lessons/src/lesson035_nil/code.gleam
new file mode 100644
index 0000000..c28080b
--- /dev/null
+++ b/lessons/src/lesson035_nil/code.gleam
@@ -0,0 +1,11 @@
+import gleam/io
+
+pub fn main() {
+ let x = Nil
+ io.debug(x)
+
+ // let y: List(String) = Nil
+
+ let result = io.println("Hello!")
+ io.debug(result == Nil)
+}
diff --git a/lessons/src/lesson035_nil/text.html b/lessons/src/lesson035_nil/text.html
new file mode 100644
index 0000000..3416643
--- /dev/null
+++ b/lessons/src/lesson035_nil/text.html
@@ -0,0 +1,15 @@
+<p>
+ <code>Nil</code> is Gleam's unit type. It is a value that is returned by
+ functions that have nothing else to return, as all functions much return
+ something.
+</p>
+<p>
+ <code>Nil</code> is not a valid value of any other types, that is values in
+ Gleam are not nullable. If the type of a value is <code>Nil</code> then it is
+ the value <code>nil</code>. If it is some other type then the value is not
+ <code>Nil</code>.
+</p>
+<p>
+ Uncomment the line that assigns <code>Nil</code> to a variable with an
+ incompatible type annotation to see the comile time error it produces.
+</p>