Types and specs

Hi all
I am trying to understand how to use Types and specs and read the article on http://elixir-lang.org/getting-started/typespecs-and-behaviours.html but it is not clear.

For example a function with spec:

 @spec add(number, number) :: {number, String.t}
  def add(x, y), do: {x + y, "You need a calculator to do that?!"}

The parameter number is from type string?
Could someone explain me with some good sample?

Thanks

1 Like

No, the function is returning a two-element tuple:

  1. The first element contains a number - the result of the addition
  2. The second element contains a String with the snarky comment: “You need a calculator to do that?!”
1 Like