-
Notifications
You must be signed in to change notification settings - Fork 0
Section 1.6: Modules and Methods
Thiago Salles edited this page Jun 28, 2021
·
1 revision
Some reserved words:
-
defmodule
define a single module of code to organize the project -
def
define a single function inside a module
We can suppress the parenthesis while calling a function if we are not providing any argument.
Calling Cards.hello
is the same as Cards.hello()
Elixir has the implicit return. The last value of the function will be automatically returned.
You can use return <value>
, but it's not needed.
Example:
def hello do
"Hello, World"
end
More to read:
Section 1: An Elixir Warmup
5 - Generating a Project
6 - Modules and Methods
7 - Lists and Strings
8 - Method Arguments
11 - Immutability
13 - Comprehensions Over Lists
Section 2: Pattern Matching
17 - Overview
18 - Relationship with Erlang
23 - The Pipe Operator
24 - Installing Dependencies
Section 3: Testing and Documentation
Section 4: A Few Side Topics