Added one more example with guards, fixed typos and identation.

This commit is contained in:
mrshankly 2013-07-03 00:03:44 +01:00
parent 231a211ef2
commit a136cfe86a

View File

@ -246,8 +246,8 @@ end
Math.sum(1, 2) #=> 3
Match.square(3) #=> 9
# To compile our little Math module save it as `math.ex` and use `elixirc`
elixirc math.ex
# To compile our simple Math module save it as `math.ex` and use `elixirc`
# in your terminal: elixirc math.ex
# Inside a module we can define functions with `def` and private functions with `defp`.
# A function defined with `def` is available to be invoked from other modules,
@ -278,6 +278,8 @@ end
Geometry.area({:rectangle, 2, 3}) #=> 6
Geometry.area({:circle, 3}) #=> 28.25999999999999801048
Geometry.area({:circle, "not_a_number"})
#=> ** (FunctionClauseError) no function clause matching in Geometry.area/1
# Due to immutability, recursion is a big part of elixir
defmodule Recursion do