6
I’m studying Elixir and I came across the keyword defmodulo
, I used to define a basic module that displays a message:
defmodule Mensagem do
def escreve(msg) do
IO.puts msg
end
end
Calling in the following way:
Mensagem.escreve("Oie amigo do gato :D")
Exit:
Look friend of the cat :D
The way the module is defined reminded me a lot of a class.
Doubts
- What is the purpose of the module in Elixir?
- A module is the same thing as a class?
- There may be instances of it to represent an object?
It seems to me that the modules in this case will not have instances, they will not be objects, the modules are closer to namespaces, as if they were functions within namespace in PHP, or defs within scopes (modules also) in Python, in fact Elixir remindedme enough as it is in Python and Ruby, the modules.
– Guilherme Nascimento