-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #61
- Loading branch information
Showing
10 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/content/chapter0_basics/lesson14_type_imports/code.gleam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import gleam/bytes_builder | ||
import gleam/string_builder.{type StringBuilder} | ||
|
||
pub fn main() { | ||
// Referring to a type in a qualified way | ||
let _bytes: bytes_builder.BytesBuilder = bytes_builder.new() | ||
|
||
// Refering to a type in an unqualified way | ||
let _text: StringBuilder = string_builder.new() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<p> | ||
Other modules may also define types that we wish to refer to. In this case we | ||
need to import them. | ||
</p> | ||
<p> | ||
Like functions types can be referred to in a <em>qualified</em> way by putting | ||
the imported module name and a dot before the type name. For example, | ||
<code>bytes_builder.BytesBuilder</code> | ||
</p> | ||
<p> | ||
Types can also be imported in an <em>unqualified</em> way by listing them in | ||
the import statement with the word <code>type</code> before the type name. | ||
</p> | ||
<p> | ||
It is more common in Gleam code for types to be imported in an unqualified way | ||
than it is for funtions to be imported in an unqualified way. | ||
</p> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.