Skip to content

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