Elixir Learning Part 2

Vincent Nguyen 28 March 2017
elixir

Import and Alias

To call a function from another module, you have to reference the module name, sometime this can be cumbersome. If your module often calls functions from another module, let's use import other module into your own.

    defmodule User do
      import IO
  
      def name do
        puts "Vincent"
      end
    end
  
    User.name # Hello Vincent
  

Module attributes

Atom

Tuples

List

Recursive list definition

That's why we SHOULD NOT add elements to the end of a list.

Or

        [a | b] = list
        a # 1
        b # [2,3,4]
  

NOTE: