Elixir first module
Livebook is great for coders
import IEx.Helpers
IEx.Helpers
Create some Elixir code
Simply click on the Elixir cell icon to build a new cell then write some code
4 + 38
42
defmodule Conversions.Metric do
def cents_to_inches(cents \\ pi()) do
cents * 2.54
end
defp pi do
3.1415
end
end
{:module, Conversions.Metric, <<70, 79, 82, 49, 0, 0, 7, ...>>, {:pi, 0}}
i(Conversions.Metric)
Term
Conversions.Metric
Data type
Atom
Module bytecode
[]
Source
#cell:gq4oqlq6exmutsspbjryalmq4mdrf4tw
Version
[198863129467447789547019270714092649129]
Compile options
[:no_spawn_compiler_process, :from_core, :no_core_prepare, :no_auto_import]
Description
Call Conversions.Metric.module_info() to access metadata.
Raw representation
:"Elixir.Conversions.Metric"
Reference modules
Module, Atom
Implemented protocols
IEx.Info, Inspect, List.Chars, String.Chars
Conversions.Metric.cents_to_inches()
7.979410000000001
Conversions.Metric.cents_to_inches(2)
5.08
exports(Conversions.Metric)
cents_to_inches/0 cents_to_inches/1
# the name will become `Metric`.
# name after the last period become alias
# the last namespace is Metric
alias Conversions.Metric
# alias Conversions.Metric, as: Metric
Conversions.Metric
Metric.cents_to_inches()
7.979410000000001
# decide not to type at all
import Conversions.Metric
Conversions.Metric
cents_to_inches()
7.979410000000001