From e66db486ffa57a1ce68a85ab6cb7bfbb05e260b8 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Mon, 4 Dec 2023 17:05:51 +0000 Subject: Start content --- lessons/src/lesson002_unqualified_imports/code.gleam | 10 ++++++++++ lessons/src/lesson002_unqualified_imports/text.html | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lessons/src/lesson002_unqualified_imports/code.gleam create mode 100644 lessons/src/lesson002_unqualified_imports/text.html (limited to 'lessons/src/lesson002_unqualified_imports') diff --git a/lessons/src/lesson002_unqualified_imports/code.gleam b/lessons/src/lesson002_unqualified_imports/code.gleam new file mode 100644 index 0000000..2708f25 --- /dev/null +++ b/lessons/src/lesson002_unqualified_imports/code.gleam @@ -0,0 +1,10 @@ +// Import the module and one of its functions +import gleam/io.{println} + +pub fn main() { + // Use the function in a qualified fashion + io.println("This is qualified") + + // Or an unqualified fashion + println("This is unqualified") +} diff --git a/lessons/src/lesson002_unqualified_imports/text.html b/lessons/src/lesson002_unqualified_imports/text.html new file mode 100644 index 0000000..8fda45e --- /dev/null +++ b/lessons/src/lesson002_unqualified_imports/text.html @@ -0,0 +1,15 @@ +

+ Normally functions from other modules are used in a qualified fashion, with + the module qualifier before function name. For example, + io.println("Hello!"). +

+

+ It is also possible to specify a list of functions to import from a module in + an unqualified fashion, such as the println function in the code + editor. Because it has been imported like this it can be referred to as just + println. +

+

+ Generally it is best to use qualified imports, as this makes it clear where + the function is defined, making the code easier to read. +

-- cgit v1.2.3