How to Read Program Arguments in Elixir Posted in Polyglotbits on 08 of Aug, 2015

Elixir is fundamentally different than many of the programming languages most people use.

This also shows in the simple task of making the Hello World program that prints a hello to each argument to the program.

defmodule Test do

def hello([head|tail]) do
  IO.write("Hello #{head}\n")
  hello tail

def hello([]) do



Since Elixir has pattern matching, either the first or the second version of the hello function is called based on wether the input array has elements or not. If the first hello method is called it prints a hello to the first element, and calls “itself” with the rest of the elements.